Xtremer360 Posted November 11, 2012 Share Posted November 11, 2012 I'm trying to figure out how to have it not select the title_status_id but only use it to run the get_title_statuses function to get the name of the status without having it return it in the object print. $titles = $this->titles_model->get_titles(array('title_ids' =>1)); echo '<pre>'; print_r($titles); echo '</pre>'; stdClass Object ( [title_id] => 1 [title_name] => Undisputed Title [title_directory_name] => undisputed [title_status_id] => 1 [title_sort_order] => 1 ) <?php public function get_titles($params = array()) { $this->db->select('titles.title_id'); $this->db->select('titles.title_name'); $this->db->select('titles.title_directory_name'); $this->db->select('titles.title_status_id'); $this->db->select('titles.title_sort_order'); $this->db->from('titles'); //checking to see if any $params are attempting to be passed if (count($params) > 0) { //start title specific selection if (isset($params['title_ids'])) { //if you only have one integer. if (is_integer($params['title_ids'])) { $this->db->where('titles.title_id', $params['title_ids']); $query = $this->db->get(); if ($query->num_rows() > 0) { $title = $query->row(); } else { return false; } } } } } ?> Link to comment https://forums.phpfreaks.com/topic/270571-mulitpurposing-a-function/ Share on other sites More sharing options...
trq Posted November 11, 2012 Share Posted November 11, 2012 Pardon? Link to comment https://forums.phpfreaks.com/topic/270571-mulitpurposing-a-function/#findComment-1391746 Share on other sites More sharing options...
ignace Posted November 12, 2012 Share Posted November 12, 2012 $this->db->select('titles.title_status_id'); Put this line in comments Link to comment https://forums.phpfreaks.com/topic/270571-mulitpurposing-a-function/#findComment-1391782 Share on other sites More sharing options...
Xtremer360 Posted November 12, 2012 Author Share Posted November 12, 2012 Basically the get_titles function will handle all kinds of situations but I'm going to try and do this one situation at a time. When the function is called with just one id (title_id) I want it to return data just about that title. When it gets the status_id I want it to take that value to the get_title_statuses function so it can get the name of that status. So the returned object should be this for a single row. stdClass Object ( [title_id] => 1 [title_name] => Undisputed Title [title_directory_name] => undisputed [title_status_name] => Active [title_sort_order] => 1 ) Link to comment https://forums.phpfreaks.com/topic/270571-mulitpurposing-a-function/#findComment-1391852 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.