'Codeigniter changes with `count_all_results`
So... it appears as if overnight, SOME-thing has changed with either the Codeigniter 4 framework or PHP in general, as my website is now down - and it seems to be centred around my call to a count_all_results
query using QueryBuilder.
My Controller:
public function index()
{
$model = new ShopModel();
$foo = $model->foo;
$bar = $model->bar;
$data = [
'foo' => $foo,
'bar' => $bar,
'first' => $model->where(['availability' => 'in stock', 'shop.sale_price < price', 'shop.sku !=' => ''])->orderBy('round(((price - shop.sale_price) / price) * 100) DESC')->first() ,
'count_all_results' => $model->countAllResults() ,
];
$data['foo']['uri']['path']['controller'] = 'shop';
echo view('default', $data);
}
Logging onto my home page I'm getting the following error:
Undefined variable $count_all_results
I've played around with this, and removed the first instance of the error, and the code is fine again... until the next instance of calling count_all_results
again.
I haven't altered or changed my code itself - this error has just 'appeared' all of a sudden! Has this been depreciated in PHP? Am I missing something obvious? Is it just a bug?
Any insight or help would be appreciated.
Solution 1:[1]
Why are you using this line of code $data['foo']['uri']['path']['controller'] = 'shop';
Try commenting on this and run again.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Sharoon |