How to manipulate parameter according to other parameter in a php function?

-XR-

New Member
I have id names with the second part of table name plus id.\[code\]For example admins_id in omc_admins table, customers_id in omc_customers table, products_id in omc_products table, categories_id in omc_categories table etc.\[/code\]Now the following function code is supposed to find orphans. For example, when I delete categories, it will check the products and find orphans of that category.Now I am not sure how to manipulate parameter according to other parameter. For example 'id' in $this->db->select('id,name');.id will be changing according to the $db_table.\[code\]function checkOrphans($segment, $id, $db_table){$data = http://stackoverflow.com/questions/2006896/array();$this->db->select('id,name');$this->db->where($id,id_clean($segment));$Q = $this->db->get($db_table);if ($Q->num_rows() > 0){ foreach ($Q->result_array() as $row){ $data[$row['id']] = $row['name']; }}$Q->free_result(); return $data; \[/code\]}I think I can use $db_table. For example $db_table is omc_categories, I can use categories part and add to id.categories_id.Can anyone tell me how to do it please?I am using codeigniter, but question is purely php.
 
Back
Top