PDO compatibilty function fetchSingle() was renamed in PDO to

fetchColumn($column_num=0): now both are available in ADOdb, thought
fetchSingle is depricated and should no longer be used!
This commit is contained in:
Ralf Becker 2009-03-25 09:03:36 +00:00
parent cc9d7445c3
commit 3b0f5e5ab2
2 changed files with 727 additions and 705 deletions

View File

@ -3408,7 +3408,8 @@
/**
* PDO compatibility function: fetch the next row
*
* @return array/boolean false if there's nothing to fetch
* @param $fetchmode=null ADODB_FETCH_{DEFAULT|ASSOC|NUM|BOTH}, default is to use currently selected fetch-mode
* @return array|boolean false if there's nothing to fetch
*/
function &fetch($fetchmode=null)
{
@ -3426,14 +3427,35 @@
}
/**
* PDO compatibility function: fetch the first column of the next row
* PDO compatibility function: fetch the n-th column of the next row
*
* @return string/boolean false if there's nothing to fetch
* @param int $column_number=0
* @return string|boolean false if there's nothing to fetch
*/
function fetchColumn($column_number=0)
{
if(!($row = $this->FetchRow()))
{
return false;
}
while ($column_number-- >= 0)
{
$ret = array_shift($row);
}
return $ret;
}
/**
* fetch the first column of the next row
*
* was introduced in eGroupware 1.6 as PDO compatibility function, but is renamed in PDO to fetchColumn()
*
* @deprecated use fetchColumn()
* @return string|boolean false if there's nothing to fetch
*/
function fetchSingle()
{
$row = $this->FetchRow();
return is_array($row) ? array_shift($row) : false;
return $this->fetchColumn();
}
} // end class ADORecordSet

View File

@ -30,8 +30,8 @@
*
* c) foreach($db->select($table,'*',$where,__LINE__,__FILE__,false,'',$app) as $row)
*
* To fetch only single column (of the next row):
* $cnt = $db->query("SELECT COUNT(*) FROM ...")->fetchSingle();
* To fetch only a single column (of the next row):
* $cnt = $db->query("SELECT COUNT(*) FROM ...")->fetchColumn($column_num=0);
*
* To fetch a next (single) row, you can use:
* $row = $db->query("SELECT COUNT(*) FROM ...")->fetch($fetchmod=null);