//$query mysqli_result //$resulttype int MYSQLI_ASSOC, MYSQLI_NUM, or MYSQLI_BOTH. Defaults to MYSQLI_BOTH. //返回值 Returns an array of strings that corresponds to the fetched row or NULL if there are no more rows in resultset. function fetch_array(/*mysqli_result*/ $query, $resulttype = MYSQLI_ASSOC) { //var_dump(!null); if(!$query || !($query instanceof mysqli_result)) return NULL; return $query- fetch_array($resulttype);// }
function data_seek($result,$offset) {
return $result- data_seek($offset);
}
function fetch_assoc($query) {
return $query- fetch_assoc();// 关联数组 }
function fetch_row($query) { return $query- fetch_row();// 索引数组,数字0,1。eg。。。 }
function fetch_fields($query) { return $query- fetch_fields(); }
//$query string //$resultmode int //返回值 如果成功则返回 TRUE,失败则返回 FALSE。 For SELECT, SHOW, DESCRIBE or EXPLAIN mysqli_query() will return a result object. public function query($sql ,$resultmode=MYSQLI_STORE_RESULT ) { if(MYSQL_OPEN_LOGS) {
function num_rows($query) { return $query- num_rows;
}
//返回值 int The number of fields from a result set. //也可以用另外一种方式 mysqliHelp- db- field_count返回。 function num_fields($query) { return $query- field_count; }
function free_result($query) { //all methods are equivalent; $query- free(); //$query- free_result(); //$query- close(); }
如果是MYSQLI_USE_RESULT,query以后得到mysqli_result对象后,执行data_seek会出错,因为 mysqli_result::data_seek() [mysqli-result.data-seek]: Function cannot be used with MYSQL_USE_RESULT
//这里如果是MYSQLI_USE_RESULT,下面的$dbHelper- data_seek($query,10);就会出错 $query=$dbHelper- query("select id,cateid,title from product limit 22",MYSQLI_STORE_RESULT ); //$query=$dbHelper- query("update product set createtime=UNIX_TIMESTAMP() limit 22");
//$query=$dbHelper- query("insert into `product`(`cateid`,`title`,`text`,`createtime`) values (2,'test','content',1284822691)"); //$query=$dbHelper- query("delete from `product` where id=1"); //$query=$dbHelper- query("replace into product(id,cateid,title,text,createtime) values(1,2,'this is demo','test',UNIX_TIMESTAMP())");