fetchCloumn () method is to obtain the result set value for the next line of the designated column, a separate return a result set from the next row. Linear motor brand
So we have in the previous two articles "Getting fetchAll result set of a PDO () method explanation" and "PDO acquire fetch the result set () method explain" we introduced two ways to get a similar result set in the PDO, so we are going to introduce fetchColumn () method with you!
Here we look at the syntax of the method under fetchColumn () as follows:
1 |
|
From the result set returned the next row an individual, if not the, FALSE is returned.
Optional parameter index value column_number column line set, from the value of zero, then If omitted, the value will start from the first column.
Get the value of the specified column in the result set by fetchColumn () method of the next line, Note: this is "in the next row in the result set of the specified column"!
Here we introduce specific uses examples to the specific usage fetchColumn () method, the following steps:
First, create a php file, web page design, even by PDO MySQL database, and then define SELECT query, use prepare () and execute () method to execute the query operation, then, by fetchColumn () method to output the result set to the next row, first column value , the output data of the ID value is, the specific code is as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
|