<?php
defined ( 'AH_CFG' ) or define( 'AH_CFG' ,'config.php');
include 'mysqli_class.php';
$link = new _ah_mysqli();
# this class only use for normal query
# for other custom query query please use $link->direct($query) and put query in $query
# please dont forget to use $link->cv($var) for scape in direct query
###########################################
################# SELECT ##################
###########################################
# The general use of the function is as follows:
$result = $link->select($fields,$table,$where,$order,$order_type,$limit_from,$limit_to);
# normal use : SELECT field FROM table WHERE condition ORDER BY order field, order type LIMIT limit from, limit to
####### field[s] #######
$fields = array('field1','field2 ');
# or
$fields = array('*');
# or for 1 field
$fields = '*';
####### table[s] #######
$table = 'table';// or join
####### condition #######
# use this method only and not worry for scape
$where = array(array('','field3','=','test',''));
$where = array(array('','field3','=','test','AND'),array('','field2','>','1',''));
$where = array(array('','field3','=','test','AND'),array('(','field2','=','1','OR'),array('','field2','=','10',')'));
# internal array mean :
# array("(,),AND,OR,...",'field only',"=,>,<,BETWEEN,...",'value',"(,),AND,OR,...")
####### order field AND order type #######
$order = 'field1';
$order_type = 'ASC';
# use multi order not need use type
$order = 'field1 ASC, field2 DESC';
$order_type = NULL;
####### limit from AND limit to #######
# if use from 0 not need use to limit to
$limit_from = 20;
# limit from 10, 20
$limit_from = 10;
$limit_to = 20;
# just use
$result = $link->select($fields,$table,$where,$order,$order_type,$limit_from,$limit_to);
# and use result
// while ($row = mysqli_fetch_array($result)) {
// # do something
// }
# if query is not return any thing then return false
###########################################
################# RESULT ##################
###########################################
# you can use result for more speed and save memory
# just like select, but this time $result is array for query
# The general use of the function is as follows:
$result = $link->result($fields,$table,$where,$order,$order_type,$limit_from,$limit_to);
# and use result as array
// foreach ($result as $res) {
// # do something
// }
/*
important :
This version can not recognize the difference between row and rows
If you are unsure of your returned item number (one or multi) use select
This problem will be resolved soon.
if query is not return any thing then return false
*/
###########################################
################## COUNT ##################
###########################################
# The general use of the function is as follows:
$res = $link->count($table,$where);
# and return count number
###########################################
################# DELETE ##################
###########################################
# The general use of the function is as follows:
$res = $link->delete ($table, $where = NULL);
# return mysqli_affected_rows for confirm
###########################################
################# INSERT ##################
###########################################
# The general use of the function is as follows:
$fields = array('field1','field2','field3','field4');
$values = array(array('value1','value1','value1','value1'));
# for multi insert values
$values = array(array('value1','value1','value1','value1'),array('value1','value1','value1','value1'));
$link->insert ($table, $fields, $values);
###########################################
################# UPDATE ##################
###########################################
# The general use of the function is as follows:
$fieldval = array(array('field1','value1'));
# multy field update
$fieldval = array(array('field1','value1'),array('field2','value2'));
update ($table, $fieldval, $where);
###########################################
###########################################
###########################################
###########################################
# next version fix array level Identifiable
# sorry for my bad english
?>
|