Detailed explanation of the fetchAll() method for obtaining the result set in PDO
The fetchAll() method obtains all rows in the result set and returns a Binary array of rows!
So in the previous article "Detailed Explanation of the fetch() Method for Obtaining Result Sets in PDO", we introduced the fetch() method to obtain the result set. We will introduce the fetchAll( ) method is similar to the previous method fetch(), but this method only needs to be called once to get all the rows in the result set and assign them to the returned array (two-dimensional).
The syntax format of the fetchAll() method is as follows:array PDOStatement::fetchAll ([ int $fetch_style [, mixed $fetch_argument [, array $ctor_args = array() ]]] )
Said Ming | |
Associative array form | |
Numeric index array form | |
Both array forms are available, this is the default | |
According to the form of the object, similar to the previous mysql_fetch_object() | |
Return the result in the form of a Boolean value, and assign the obtained column value to the variable specified in the bindParam() method | |
to Results are returned in three forms: associative array, numeric index array, and object. |
prepare($query);//准备查询语句 $res->execute(); //执行查询语句,并返回结果集 ?>
id | 用户名 | 密码 |
Detailed Explanation of the fetchColumn() Method for Obtaining Result Sets in PDO"!
The above is the detailed content of Detailed explanation of the fetchAll() method for obtaining result sets in PDO. For more information, please follow other related articles on the PHP Chinese website!