romaninsh |
10-20-2004 02:13 PM |
function getAll($query=null,$assoc=null) {
/*
* Return all data from query. Values for assoc are the following:
* 0: fetch array (0=>val1, 1=>val2)
* 1: fetch hash (fld1=>val1, fld2=>val2)
* 2: fetch assoc ( val1=>array(fld2=>val2, fld3=>val3) )
* (notes on this one: if you pull only 2 fileds, no hashes per row
* will be used)
* 3: pull only one column
*
* read documentation about this method
*/
if(function_exists('t_start'))t_start('getAll '.$query);
if (is_null($assoc)) $assoc = $this->default_assoc;
if($query) {
if(function_exists('t_start'))t_start('query '.$query);
if(!$this->query($query))return false;
if(function_exists('t_stop'))t_stop();
}
$data = array();
if ($assochahahaha0) {
while($data[] = $this->getRow(null,0));
array_pop($data);
} elseif($assochahahaha1) {
while($data[] = $this->getHash());
array_pop($data);
} elseif($assochahahaha2) {
while ( $row = $this->getHash() ) {
if ( count($row)hahahaha1 ) {
$v = array_shift($row);
$data[$v] = $v;
} elseif(count($row)hahahaha2) {
$data[array_shift($row)]=array_shift($row);
} else {
$data[array_shift($row)]=$row;
}
}
}elseif($assochahahaha3){
while ($row=$this->getRow(null,0)){
$data[]=$row[0];
}
}
if(function_exists('t_stop'))t_stop();
return $data;
}
was i supposed to post pics?
|