# Find()-\>count() gives InvalidArgumentException

**URL:** <https://discourse.cakephp.org/t/find-count-gives-invalidargumentexception/9144>\
**Category:** Need Help\
**Created:** [March 20, 2021, 11:31am UTC](https://discourse.cakephp.org/t/find-count-gives-invalidargumentexception/9144 "2021-03-20T11:31:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Roridula](https://avatars.discourse-cdn.com/v4/letter/r/ba8739/32.png) [@Roridula](https://discourse.cakephp.org/u/Roridula)\
**Post date:** [March 20, 2021, 11:31am UTC](https://discourse.cakephp.org/t/find-count-gives-invalidargumentexception/9144/1 "2021-03-20T11:31:39Z")

</div>

I am really feeling stupid, but I do not manage to count. What am I doing wrong here?

In my controller:  
(as written in [Query Builder - 4.x](https://book.cakephp.org/4/en/orm/query-builder.html#query-count))

$this-\>loadModel(‘Measurements’);  
$total = $this-\>Measurements-\>find()-\>where([‘id’ =\> $ids])-\>count();

I get the error message " Cannot convert value of type `array` to string - InvalidArgumentException"

---

<div class="post-metadata">

**Author:** ![Jawfin](https://avatars.discourse-cdn.com/v4/letter/j/dbc845/32.png) [@Jawfin](https://discourse.cakephp.org/u/Jawfin)\
**Post date:** [March 20, 2021, 12:50pm UTC](https://discourse.cakephp.org/t/find-count-gives-invalidargumentexception/9144/2 "2021-03-20T12:50:02Z")

</div>

Looking at the link provided, and at your code, and the error message, I assume that `$ids` is an array?

In which case try: -

```auto
$this->loadModel(‘Measurements’);
$total = $this->Measurements->find()->where(['id IN' => $ids])->count();

```

Untested; but its seems you need to use the **IN** statement in your query.  
[https://book.cakephp.org/4/en/orm/query-builder.html#automatically-creating-in-clauses](https://book.cakephp.org/4/en/orm/query-builder.html#automatically-creating-in-clauses)

---

<div class="post-metadata">

**Author:** ![Roridula](https://avatars.discourse-cdn.com/v4/letter/r/ba8739/32.png) [@Roridula](https://discourse.cakephp.org/u/Roridula)\
**Post date:** [March 20, 2021, 1:21pm UTC](https://discourse.cakephp.org/t/find-count-gives-invalidargumentexception/9144/3 "2021-03-20T13:21:19Z")

</div>

Great, thank you so much. I guessed it was some stupid detail.
