<?php

namespace Hura8\Database;

interface iConnectDB
{

    public function isConnected(): bool;

    public function ping() ;

    /**
     * @param string $query
     * @param array $bind_types
     * @param array $bind_values
     * @param bool $get_affected_row_or_id get the affected row or newly insert-id from the query, default return the mysqli_result
     * @return \mysqli_result | false | int
     */
    public function runQuery($query, array $bind_types=[], array $bind_values=[], $get_affected_row_or_id = false);

    /**
     * @deprecated Unsafe, make sure all variables are properly escaped
     */
    public function multi_query(array $array_query);


    // a simple utitily method which we use very frequently
    public function getItemInfo($table_name, $id_value, $id_field = 'id');

    //$table_name = 'table_abc'
    /*$fields = array(
            "field_name_1",
        );*/
    /*$where_condition = array(
        "field_name_1" => ["=", "value_1"],
        "field_name_2" => ["LIKE", "value_1"],
    );*/
    public function select($table_name, $fields =[],  $where_condition=[],  $order_by = '', $limit='1');


    /**
     * @param \mysqli_result | false $resource
     * @return array|null
     */
    public function fetchAssoc( $resource);

    /**
     * @param \mysqli_result | false $resource
     * @return array|mixed
     */
    public function fetchAll($resource);

    public function getErrorNo();

}
