Database Abstraction Layer for PHP

User Tools

Site Tools


This is an old revision of the document!


 mixed getCol {
       mixed $sql
       optional string[] $bindvars
       optional bool $trimString


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 the variables $ADODB_FETCH_MODE and $ADODB_ASSOC_CASE and the function setFetchMode().

For a detailed description of the SQL and bind parameters passed, see execute().

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.


 * DB2 Connection assumed
$ar = $db->getCol("SELECT * FROM ACT");
 * $ar returns:
    [0] => 10
    [1] => 20
    [2] => 30
v5/reference/connection/getcol.1461285417.txt.gz · Last modified: 2017/04/21 11:35 (external edit)