v6:reference:connection:getcol
getCol
syntax
mixed getCol {
mixed $sql
optional string[] $bindvars=null
optional bool $trimString=false
optional string[] cacheOptions=null
} returns array|null
Description
The function executes a statement and returns the first column of each row of the the entire recordset in an array or false if the statement execution fails. If no records match the provided SQL statement, an empty array is returned.
The presentation of the returned data can be modified by:
- fetchMode class variable,
- assocCase class variable,
- setFetchMode() function.
For a detailed description of the SQL and bind parameters passed, see execute(). The statement also supports use of the Memcache service
The optional third parameter passed enables space trimming of the returned value. This is only relevant if the returned string is coming from a CHAR type field.
Usage
/* * DB2 Connection assumed */ $ar = $db->getCol("SELECT * FROM ACT"); /* * $ar returns: Array ( [0] => 10 [1] => 20 [2] => 30 ....... */
v6/reference/connection/getcol.txt · Last modified: by 127.0.0.1
