php-activerecord
php-activerecord copied to clipboard
count(): Parameter must be an array or an object that implements Countable in ActiveRecord\Model::find_by_pk() (line 1670 of php-activerecord/lib/Model.php)
count(): Parameter must be an array or an object that implements Countable in ActiveRecord\Model::find_by_pk() (line 1670 of php-activerecord/lib/Model.php) PHP 7.2
I have the same problem
same are there solutions ?
you can hack use Model::first(['id' => $id]) instead of Model::find($id) :))
not an option if table has more than one primary key and you need more than one result. My solution 1670 line of Model.php: if ($results != ($expected = count((array)$values)))
yes, just a small hack that worked for me, until your PR is not merged
Currently dealing with this on a site that I want to update from PHP 7.1 => 7.2. I'm pulling in php-activerecord/php-activerecord
via composer currently and cannot hack the core to fix this.
Hi. I am also pulling via composer. Looking forward for a fix. Thanks!
Instead of modifying the core function you could also use: Model::find(array($id));
also this variant working Model::find_by_id($id);