[Resolved] Query returns results in phpMyAdmin but doesn't with ActiveRecord - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: [Resolved] Query returns results in phpMyAdmin but doesn't with ActiveRecord (/showthread.php?tid=26829) Pages:
1
2
|
[Resolved] Query returns results in phpMyAdmin but doesn't with ActiveRecord - El Forum - 01-24-2010 [eluser]kirkaracha[/eluser] I have this query in my model: Code: public function get_person_office_info($person_office_id) { That doesn't any results, even though I know there are results from looking at the database. $this->db->last_query()): Code: SELECT `people_offices`.`office_start_date`, `people_offices`.`office_end_date` FROM (`people_offices`) WHERE `id` = '53' LIMIT 1 When I copy that query into phpMyAdmin, it returns the expected results. Here's how I'm calling it from the controller: Code: $person_office_id = $this->uri->segment(3,0); get_where doesn't work, either: Code: public function get_person_office_info($person_office_id) { Produces: Code: SELECT * FROM (`people_offices`) WHERE `id` = '53' LIMIT 1 Again, works in phpMyAdmin, doesn't work in CI. [Resolved] Query returns results in phpMyAdmin but doesn't with ActiveRecord - El Forum - 01-24-2010 [eluser]JHackamack[/eluser] Have you made sure you are calling the correct database in your config file? [Resolved] Query returns results in phpMyAdmin but doesn't with ActiveRecord - El Forum - 01-24-2010 [eluser]kirkaracha[/eluser] Yes. I know the $person_office_id is a valid database ID because it's generated from a query. [Resolved] Query returns results in phpMyAdmin but doesn't with ActiveRecord - El Forum - 01-24-2010 [eluser]JHackamack[/eluser] I wasn't talking about the ID value, I was talking about the database.php file in the Application/Config directory Making sure the database name is correctly set [Resolved] Query returns results in phpMyAdmin but doesn't with ActiveRecord - El Forum - 01-24-2010 [eluser]kirkaracha[/eluser] Yes, the database name is correct. If it wasn't, I wouldn't be able to do the initial query. [Resolved] Query returns results in phpMyAdmin but doesn't with ActiveRecord - El Forum - 01-24-2010 [eluser]JHackamack[/eluser] When you say the query doesn't work what do you mean? It loads a blank white page, it comes up with a MySQL Error? Do you have a piece of the view that you can paste in? [Resolved] Query returns results in phpMyAdmin but doesn't with ActiveRecord - El Forum - 01-24-2010 [eluser]kirkaracha[/eluser] The view loads fine, without any database errors. The result_array is empty when I do var_dump($this->db->last_query()); Code: object(CI_DB_mysql_result)#20 (7) { [Resolved] Query returns results in phpMyAdmin but doesn't with ActiveRecord - El Forum - 01-24-2010 [eluser]JHackamack[/eluser] How are you calling the result array? Is it something like this? Code: foreach($results->result() as $row) { [Resolved] Query returns results in phpMyAdmin but doesn't with ActiveRecord - El Forum - 01-24-2010 [eluser]JanDoToDo[/eluser] As above... What does this do? $results = $this -> db -> get() $return = $results -> result_array(); var_dump($return); [Resolved] Query returns results in phpMyAdmin but doesn't with ActiveRecord - El Forum - 01-24-2010 [eluser]kirkaracha[/eluser] I'm at a sports bar, will check this evening. |