Welcome Guest, Not a member yet? Register   Sign In
Select query not returning results (database problem?)
#1

[eluser]azavala[/eluser]
I must be tired and have overlooked something in my code. I hope thats the case anyway. Basically, I have a simple model that selects a database entry in a table by a specified number (ID#). The controller takes the user specified ID# and calls the model to pull up that record. The problem is that even though the table I'm trying to pull records from has plenty of entries in it, the model always returns FALSE (see code below) as if no records were found. I tried changing the query to select data differently, I tried changing the AR code in the model (ie using $this->db->where() with this->db->get(), etc). Always nothing.

I tried running the same query in my mysql database admin app and it also returns nothing. I can, however, select * from the table and get the entries. Also, the other models that work with this table function just fine. The other models add and delete records from the same table without any issues. I just can't seem to select a specific entry, regardless if it be by it's ID# or name, or whatever.

Been working on this project for a long time and I have a few other models that work the same way with other tables. Never had a problem like this. Is there something wrong with my db table? Should I try creating a new one to replace it and give it a try?

Here's my code incase...

Model:
Code:
function getCategory($cat_id)
    {
        $this->db->where('video_cat_id', $cat_id);
        $catquery = $this->db->get('videos_categories');
        
        if (!$catquery->num_rows() > 0)
        {
            // Category was not found in the database
            return FALSE;
        }
        else
        {    
            // Category found, return data
            $row = $catquery->row_array();
            
            $vidCategory['title'] = $row['video_cat_name'];
            $vidCategory['id'] = $row['video_cat_id'];
            $vidCategory['description'] = $row['video_cat_description'];
            $vidCategory['tags'] = $row['video_cat_tags'];
            $vidCategory['url'] = $row['video_cat_url'];
            
            return $featureVid;
        }
    }

Controller:
Code:
$catData = $this->videos_model->getCategory($data);
                
                // Check for a valid category
                if (!$catData)
                {
                    // Invalid Category ID
                    show_error('Invalid Category ID');
                }
                else
                {
                    // Category ID Valid, display edit form
                    $this->page_data['category_data'] = $catData;

                    // Output
                                        $this->page_data['content_view'] = $this->load->view('admin/admin_response', $this->page_data, TRUE);        
                    $this->load->view('admin_page', $this->page_data);    
                }

Appreciate any input on this...


Messages In This Thread
Select query not returning results (database problem?) - by El Forum - 08-23-2010, 06:35 PM
Select query not returning results (database problem?) - by El Forum - 08-24-2010, 12:20 AM
Select query not returning results (database problem?) - by El Forum - 08-24-2010, 01:43 AM
Select query not returning results (database problem?) - by El Forum - 08-24-2010, 03:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB