![]() |
Call to model returning boolean instead of array - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Call to model returning boolean instead of array (/showthread.php?tid=85904) |
Call to model returning boolean instead of array - bassmandc - 12-19-2022 I have four tables that each have a virtually identical model. Three of them work perfectly, but one returns boolean instead of an array of results. I'm racking my brain trying to figure this out. I can replace the model calls in the controller line-by-line with the equivalent calls from any other model, and I get the expected array. I put the fourth one in and I get a boolean. The only difference I can see / find is that the table that is returning boolean only has a single line of data, where the others have multiple lines of data. What am I missing here? TeamsModel.php: Code: <?php TestController.php: Code: <?php test.php (View) Code: <?= $this->extend('layouts/default') ?> Result: TEST 1: bool(true) RE: Call to model returning boolean instead of array - kenjis - 12-19-2022 array_sort_by_multiple_keys() returns bool. See https://codeigniter.com/user_guide/helpers/array_helper.html#array_sort_by_multiple_keys RE: Call to model returning boolean instead of array - bassmandc - 12-19-2022 Thanks a bunch for the solution. I'm a dummy - I just realized the difference between where I was getting the boolean was that I assigned it to a variable in this one, where I simply ran the function in the others. Returned boolean: $var = array_sort_by_multiple_keys($teams, [ 'team_name' => SORT_ASC, ]); Returns sorted array: array_sort_by_multiple_keys($teams, [ 'team_name' => SORT_ASC, ]); Time to put down my mouse and pick up a whiskey. Thanks again. |