[eluser]woomacoder[/eluser]
Hello Everybody,
I have a problem (logical problem) with Managed my category and subcategory database; the code is it:
Code:
public function GetCats($UriString)
{
$DataSet = self::GetCatsRel($UriString);
foreach($DataSet->result() as $Row)
{
$sql = "SELECT
c.id as cat_id, c.sub_cats as sub_cats,
c.name as cat_name, c.end as cat_end,
c.warning as cat_warning, c.class as cat_class,
c.completed as cat_completed
FROM cats as c
WHERE c.id = ".$Row->cat_id."
AND c.macro_id = ".$Row->macro_id." ;";
$DataSet = $this->db->query($sql);
foreach($DataSet->result() as $Row)
{
if($Row->sub_cats != 0)
{
echo "INCAZUS";
break;
}
}
}
return $DataSet;
}
public function GetCatsRel($UriString)
{
// query String
$sql = "SELECT
r.id, r.macro_id as macro_id, r.cat_id as cat_id, r.subcat_id
FROM relcats as r
WHERE macro_id = ".$this->db->escape($UriString);
// eseguo la queyr
return $this->db->query($sql);
}
INCAZUS is my personal word to identified a right status, where code works!
I have two table:
CATS table, with id, sub_cat (counter of subcategory), name and some values.
SUBCATS table, with id, parent cat id (for related subcategory with father's category) and some values.
But...

php print_r reports:
Code:
CI_DB_mysql_result Object ( [conn_id] => Resource id #28 [result_id] => Resource id #48 [result_array] => Array ( ) [result_object] => Array ( [0] => stdClass Object ( [cat_id] => 6 [sub_cats] => 0 [cat_name] => Prova dopo ciclo [cat_end] => 2009-04-24 12:51:01 [cat_warning] => 0000-00-00 00:00:00 [cat_class] => B [cat_completed] => 0 ) ) [current_row] => 0 [num_rows] => 1 [row_data] => )
The code pass the latest value of the CATS table!!!
Why? Where is the error?
Thanks and sorry for bad english