mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
static strip_array_keys method to strip a colum-prefix from a result, docu update about depricated functions which use the internal result-set
This commit is contained in:
parent
09556f8fb0
commit
407b4defad
@ -183,8 +183,11 @@ class egw_db
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return int id of current query
|
* Return the result-object of the last query
|
||||||
*/
|
*
|
||||||
|
* @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone
|
||||||
|
* @return ADORecordSet
|
||||||
|
*/
|
||||||
function query_id()
|
function query_id()
|
||||||
{
|
{
|
||||||
return $this->Query_ID;
|
return $this->Query_ID;
|
||||||
@ -476,8 +479,10 @@ class egw_db
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Discard the current query result
|
* Discard the current query result
|
||||||
*/
|
*
|
||||||
|
* @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone
|
||||||
|
*/
|
||||||
function free()
|
function free()
|
||||||
{
|
{
|
||||||
unset($this->Query_ID); // else copying of the db-object does not work
|
unset($this->Query_ID); // else copying of the db-object does not work
|
||||||
@ -572,6 +577,7 @@ class egw_db
|
|||||||
*
|
*
|
||||||
* Specifying a fetch_mode only works for newly fetched rows, the first row always gets fetched by query!!!
|
* Specifying a fetch_mode only works for newly fetched rows, the first row always gets fetched by query!!!
|
||||||
*
|
*
|
||||||
|
* @deprecated use foreach(query() or foreach(select() to loop over the query using the global db object
|
||||||
* @param int $fetch_mode ADODB_FETCH_BOTH = numerical+assoc keys (eGW default), ADODB_FETCH_ASSOC or ADODB_FETCH_NUM
|
* @param int $fetch_mode ADODB_FETCH_BOTH = numerical+assoc keys (eGW default), ADODB_FETCH_ASSOC or ADODB_FETCH_NUM
|
||||||
* @return bool was another row found?
|
* @return bool was another row found?
|
||||||
*/
|
*/
|
||||||
@ -627,6 +633,7 @@ class egw_db
|
|||||||
/**
|
/**
|
||||||
* Move to position in result set
|
* Move to position in result set
|
||||||
*
|
*
|
||||||
|
* @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone
|
||||||
* @param int $pos required row (optional), default first row
|
* @param int $pos required row (optional), default first row
|
||||||
* @return boolean true if sucessful or false if not found
|
* @return boolean true if sucessful or false if not found
|
||||||
*/
|
*/
|
||||||
@ -748,6 +755,7 @@ class egw_db
|
|||||||
/**
|
/**
|
||||||
* Number of rows in current result set
|
* Number of rows in current result set
|
||||||
*
|
*
|
||||||
|
* @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone
|
||||||
* @return int number of rows
|
* @return int number of rows
|
||||||
*/
|
*/
|
||||||
function num_rows()
|
function num_rows()
|
||||||
@ -758,6 +766,7 @@ class egw_db
|
|||||||
/**
|
/**
|
||||||
* Number of fields in current row
|
* Number of fields in current row
|
||||||
*
|
*
|
||||||
|
* @deprecated use the result-object returned by query() or select() direct, so you can use the global db-object and not a clone
|
||||||
* @return int number of fields
|
* @return int number of fields
|
||||||
*/
|
*/
|
||||||
function num_fields()
|
function num_fields()
|
||||||
@ -813,6 +822,7 @@ class egw_db
|
|||||||
/**
|
/**
|
||||||
* Returns a query-result-row as an associative array (no numerical keys !!!)
|
* Returns a query-result-row as an associative array (no numerical keys !!!)
|
||||||
*
|
*
|
||||||
|
* @deprecated use foreach(query() or foreach(select() to loop over the query using the global db object
|
||||||
* @param bool $do_next_record should next_record() be called or not (default not)
|
* @param bool $do_next_record should next_record() be called or not (default not)
|
||||||
* @param string $strip='' string to strip of the column-name, default ''
|
* @param string $strip='' string to strip of the column-name, default ''
|
||||||
* @return array/bool the associative array or False if no (more) result-row is availible
|
* @return array/bool the associative array or False if no (more) result-row is availible
|
||||||
@ -823,17 +833,7 @@ class egw_db
|
|||||||
{
|
{
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
$result = array();
|
return $strip ? self::strip_array_keys($this->Record,$strip) : $this->Record;
|
||||||
foreach($this->Record as $column => $value)
|
|
||||||
{
|
|
||||||
if (!is_numeric($column))
|
|
||||||
{
|
|
||||||
if ($strip) $column = str_replace($strip,'',$column);
|
|
||||||
|
|
||||||
$result[$column] = $value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1774,4 +1774,19 @@ class egw_db
|
|||||||
|
|
||||||
return $this->query($sql,$line,$file,$offset,$offset===False ? -1 : (int)$num_rows,false,ADODB_FETCH_ASSOC);
|
return $this->query($sql,$line,$file,$offset,$offset===False ? -1 : (int)$num_rows,false,ADODB_FETCH_ASSOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Strip eg. a prefix from the keys of an array
|
||||||
|
*
|
||||||
|
* @param array $arr
|
||||||
|
* @param string/array $strip
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
static function strip_array_keys($arr,$strip)
|
||||||
|
{
|
||||||
|
$keys = array_keys($arr);
|
||||||
|
|
||||||
|
return array_walk($keys,create_function('&$v,$k,$strip','$v = str_replace($strip,\'\',$v);'),$strip) ?
|
||||||
|
array_combine($keys,$arr) : $arr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user