I have an application using Codeigniter/Datamapper. There is a table for Doctors, and a table for Specialties and the models are set up to have a many-to-many relationship.
I noticed that trying to query the doctors by specialty is resulting in it just querying for all of the doctors. Has anyone had this issue before? Here is the code I'm using:
$s = new Specialty();
$s->where('id',$id)->get(); //thought maybe get_by_id($id) was causing the issue, it wasnt...
$this->out['query'] = $s->doctor->order_by('last_name','asc')->get_sql();
$docs = $s->doctor->order_by('id')->get_iterated();
The $this->out['query'] responds with the following sql query:
"SELECT * FROM (`doctors`) ORDER BY `doctors`.`last_name` asc"
Another weird thing is that the results aren't coming back ordered by last_name, but I'm assuming its something in how the array gets passed to the json_encode function.