I am using the following code in my db-wrapper
Code: Select all
<?php
function arrayComplete($SqlString=false,$resourceId=false)
//returns all relevant records in database in
//a one-dimensional associative array.
{
$parent=$this->arrays($SqlString,$resourceId);
while($children=$this->arrays($SqlString,$resourceId))
{
$parent=array_merge_recursive($parent,$children);
}
return $parent;
}
?>
This basically grabs one array from the db, assigns it to $parent, then loops the SQL-query and uses
array_merge_recursive to merge the arrays the way they should be. Returns a one-dimensional associative array.
You will need a db-array function. Mine looks this:
Code: Select all
<?php
function arrays($SqlString=false,$resourceId=false)
//simply returns the typical associative array you get with
//mysql_fetch_array
{
if(!empty($SqlString))
{
$this->query($SqlString);
$arrays = mysql_fetch_assoc($this->query_id);
}
elseif(!empty($resourceId))
{
$arrays = mysql_fetch_assoc($resourceId);
}
elseif(empty($SqlString) && empty($resourceId))
{
$arrays = mysql_fetch_assoc($this->query_id);
}
return $arrays;
}
?>
P.S.: My experience with PEAR is, unfortunately, just like yours. Very bulky, too complicated and the results are at best mediocre. For some reason I tend to look at
http://www.phpclasses.org or PEAR and then don't like them. I usually ended up writing my own. But it's good to have had a look at those examples.