Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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) #588

Open
explod3r opened this issue Feb 8, 2018 · 9 comments

Comments

@explod3r
Copy link

explod3r commented Feb 8, 2018

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

@nurmuhammet-ali
Copy link

I have the same problem

@salvatorelapi
Copy link

same are there solutions ?

@explod3r explod3r reopened this May 18, 2018
@Axu1g
Copy link

Axu1g commented May 21, 2018

you can hack
use Model::first(['id' => $id])
instead of Model::find($id) :))

@explod3r
Copy link
Author

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)))

@Axu1g
Copy link

Axu1g commented May 21, 2018

yes, just a small hack that worked for me, until your PR is not merged

@natenolting
Copy link

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.

@ajanini
Copy link

ajanini commented Mar 27, 2019

Hi. I am also pulling via composer. Looking forward for a fix. Thanks!

@QuackBtz
Copy link

Instead of modifying the core function you could also use:
Model::find(array($id));

@azazellolvv
Copy link

also this variant working Model::find_by_id($id);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants