0

I have a working phalcon application. I moved it from windows to linux server everything works proper. But when i want to use phalcon model findby resultset it returns different result. I use Phalcon 2.0.13

$userRoles = UserRoles::findByUserId($userId);               
var_dump($userRoles->count()); //Returns -1
var_dump(count($userRoles)); // Returns -1
var_dump(count($userRoles->toArray())); // Returns 3 and when i var_dump result result is right there are 3 records

foreach ($userRoles as $role) { //This foreach doesnt work because result length is -1           
    $roleArr = Auth::rolesParse($role->role_id);
    $roles = array_merge_recursive($roles, $roleArr);
}

I have many samples of this code, so converting all the resultsets to array is not solution to me. I don't know is it about php extensions, configuration or phalcon configuration

(array)[Number of Elements: 3]
0: 
(array)[Number of Elements: 3]
"id": 
(string) 2049
"role_id": 
(string) 1
"user_id": 
(string) 28
1: 
(array)[Number of Elements: 3]
"id": 
(string) 2050
"role_id": 
(string) 2
"user_id": 
(string) 28
2: 
(array)[Number of Elements: 3]
"id": 
(string) 2051
"role_id": 
(string) 3
"user_id": 
(string) 28
Timothy
  • 2,004
  • 3
  • 23
  • 29
  • 1
    I am guessing the data in your Windows and Linux database aren't the same? – Timothy Aug 25 '16 at 16:34
  • The servers uses same source as database, there is no difference. I attached var_dump file to my question – Fuat Sayra ÖZDEN Aug 26 '16 at 06:24
  • I removed passwords thank you for your warning.It works when i convert them to array but there is hundreds of them and it is very difficult to convert them all. I need to find another solution :( By the way I added var_dump($userRoles->toArray() – Fuat Sayra ÖZDEN Aug 26 '16 at 06:56
  • Does the `$userId` in `UserRoles::findByUserId($userId)` exist in both databases? – Timothy Aug 26 '16 at 07:10
  • Yes, database is same just connecting from different applications. When I var_dump($userRoles->toArray()); two applications give same result. When I count them windows server gives (3) linux server gives (-1) And linux server doesnt make foreach loop – Fuat Sayra ÖZDEN Aug 26 '16 at 07:11
  • if `var_dump($userRoles->toArray())` gives the same result in both cases, how then, is it even possible that counting gives `-1` ...? And why is it even `-1`, I have never seen that before. How can an array have a negative amount of items. There sure is some dark magic going on here... – Timothy Aug 26 '16 at 09:29
  • I guess it might be because of server configuration or phalcon installation. But i don't know and it is very bad to have this problem. – Fuat Sayra ÖZDEN Aug 26 '16 at 11:51

0 Answers0