Runs the query provided and puts the
first column of data into an array
then frees the result set.
Parameter
string
$query
the SQL query or the statement to prepare
mixed
$col
which column to return (integer [column
number, starting at 0] or string [column name])
mixed
$params
array, string or numeric data to be added to the prepared statement.
Quantity of items passed must match quantity of placeholders in the
prepared statement: meaning 1 placeholder for non-array
parameters or 1 placeholder per array element.
Check the database related section of
PHP Manual
to detect the reason for this error. In most cases
a malformed SQL statement is the cause of the
error. (Ie. using LIMIT in a SQL-Statment for an Oracle
database.)
<?php
// Once you have a valid DB object named $db...
$data =& $db->getCol('SELECT cf, df FROM foo');
if (PEAR::isError($data)) {
die($data->getMessage());
}
print_r($data);
?>
<?php
// Once you have a valid DB object named $db...
$data =& $db->getCol('SELECT cf, df FROM foo', 1);
if (PEAR::isError($data)) {
die($data->getMessage());
}
print_r($data);
?>
<?php
// Once you have a valid DB object named $db...
$data =& $db->getCol('SELECT cf, df FROM foo', 'df');
if (PEAR::isError($data)) {
die($data->getMessage());
}
print_r($data);
?>
<?php
// Once you have a valid DB object named $db...
$data =& $db->getCol('SELECT cf, df FROM foo WHERE nf = ?',
'df', 5);
if (PEAR::isError($data)) {
die($data->getMessage());
}
print_r($data);
?>
<?php
// Once you have a valid DB object named $db...
$data =& $db->getCol('SELECT cf, df FROM foo WHERE nf IN (?, ?)',
'df', array(5, 10));
if (PEAR::isError($data)) {
die($data->getMessage());
}
print_r($data);
?>