# How i can run find(all) with condition array by id

**URL:** <https://discourse.cakephp.org/t/how-i-can-run-find-all-with-condition-array-by-id/1916>\
**Category:** Need Help\
**Created:** [January 24, 2017, 3:52am UTC](https://discourse.cakephp.org/t/how-i-can-run-find-all-with-condition-array-by-id/1916 "2017-01-24T03:52:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anhnt](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/anhnt/32/499_2.png) [@anhnt](https://discourse.cakephp.org/u/anhnt)\
**Post date:** [January 24, 2017, 3:52am UTC](https://discourse.cakephp.org/t/how-i-can-run-find-all-with-condition-array-by-id/1916/1 "2017-01-24T03:52:06Z")

</div>

Hi everybody!  
I am a newbie. I am using CakePHP 3.x. I want get all data in Users table. This is my code:

$userId = array(1,2,3,4,5,6,7,8,9,10);  
$this-\>Users-\>find(‘all’, array(  
‘conditions’ =\> array(‘[Users.id](http://Users.id)’ =\> $userId),  
‘fields’ =\> array(‘name’, ‘email’)  
))-\>toArray();  
But it get Error: [InvalidArgumentException] Cannot convert value to integer.

So, I have to do.  
Please help me.  
Thank you so much.

---

<div class="post-metadata">

**Author:** ![justrohu](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/justrohu/32/192_2.png) [@justrohu](https://discourse.cakephp.org/u/justrohu)\
**Post date:** [January 24, 2017, 4:04am UTC](https://discourse.cakephp.org/t/how-i-can-run-find-all-with-condition-array-by-id/1916/2 "2017-01-24T04:04:27Z")

</div>

Add IN inside where condition see below:

$userId = array(1,2,3,4,5,6,7,8,9,10);  
$this-\>Users-\>find(‘all’, array(  
‘conditions’ =\> array(‘[Users.id](http://Users.id) IN’ =\> $userId),  
‘fields’ =\> array(‘name’, ‘email’)  
))-\>toArray();

---

<div class="post-metadata">

**Author:** ![anhnt](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/anhnt/32/499_2.png) [@anhnt](https://discourse.cakephp.org/u/anhnt)\
**Post date:** [January 24, 2017, 4:08am UTC](https://discourse.cakephp.org/t/how-i-can-run-find-all-with-condition-array-by-id/1916/3 "2017-01-24T04:08:34Z")

</div>

oh great, It work perfect. Thank you so much.
