Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * get_titles function.
- *
- * @access public
- * @param array $params (default: array();)
- * possible array keys:
- * titles - either an array of titles or single title (can be title ids or title names)
- * title_statuses - either an array of title statuses or a single status (can be title status_id or title status name)
- *
- * @return object/row/specific field value if only one title is requested
- * Should return title_id, title_name, title_directory_name, title_sort_order, title_status_name for each title retrieved
- */
- 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_sort_order');
- $this->db->select('title_statuses.title_status_name');
- $this->db->from('titles');
- $this->db->join('title_statuses', 'titles.title_status_id = title_statuses.title_status_id');
- //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']);
- }
- }
- else
- {
- if (is_array($params['title_ids']))
- {
- foreach($params['title_ids'] as $title_id)
- {
- $this->db->where('title_id', $title_id);
- }
- }
- }
- }
- $query = $this->db->get();
- if ($query->num_rows() > 0)
- {
- return $query->row();
- }
- else
- {
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement