mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-21 02:18:28 +02:00
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:
parent
cc9d7445c3
commit
3b0f5e5ab2
@ -3408,7 +3408,8 @@
|
|||||||
/**
|
/**
|
||||||
* PDO compatibility function: fetch the next row
|
* 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)
|
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()
|
function fetchSingle()
|
||||||
{
|
{
|
||||||
$row = $this->FetchRow();
|
return $this->fetchColumn();
|
||||||
return is_array($row) ? array_shift($row) : false;
|
|
||||||
}
|
}
|
||||||
} // end class ADORecordSet
|
} // end class ADORecordSet
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@
|
|||||||
*
|
*
|
||||||
* c) foreach($db->select($table,'*',$where,__LINE__,__FILE__,false,'',$app) as $row)
|
* c) foreach($db->select($table,'*',$where,__LINE__,__FILE__,false,'',$app) as $row)
|
||||||
*
|
*
|
||||||
* To fetch only single column (of the next row):
|
* To fetch only a single column (of the next row):
|
||||||
* $cnt = $db->query("SELECT COUNT(*) FROM ...")->fetchSingle();
|
* $cnt = $db->query("SELECT COUNT(*) FROM ...")->fetchColumn($column_num=0);
|
||||||
*
|
*
|
||||||
* To fetch a next (single) row, you can use:
|
* To fetch a next (single) row, you can use:
|
||||||
* $row = $db->query("SELECT COUNT(*) FROM ...")->fetch($fetchmod=null);
|
* $row = $db->query("SELECT COUNT(*) FROM ...")->fetch($fetchmod=null);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user