Jump to content

Recommended Posts

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

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
)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.