משהו בסגנון הזה?
PHP קוד:
public function get_by_parent_recursive($lang = '', $parentID = 0, $arr = array())
{
$this->db->where('lang', $lang);
$this->db->where('parentID', $parentID);
$query = $this->db->get('pages');
$results = $query->result_array();
if ($query->num_rows() > 0)
{
$results = $results[0];
// Recall the function
$arr = $this->get_by_parent_recursive('he', $results['ID'], $results);
// Merging the parent and it's child arrays
//
// while the page's settings related fields are taken from the parent's
// and the content related fields from the child's
if (count($arr) > 0)
{
if (empty($results['content']))
$results['content'] = $arr['content'];
if (empty($results['title']))
$results['title'] = $arr['title'];
if (empty($results['name']))
$results['name'] = $arr['name'];
}
}
return $results;
}