-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Phalcon\Mvc\Model\Resultset\Simple::toArray() gives wrong result if empty #1377
Comments
What version of Phalcon do you use? |
The version 1.2.3 |
Could you please try this patch and see if it works for you: diff --git a/ext/mvc/model/resultset/simple.c b/ext/mvc/model/resultset/simple.c
index 3be317d..06d3c7d 100644
--- a/ext/mvc/model/resultset/simple.c
+++ b/ext/mvc/model/resultset/simple.c
@@ -336,6 +336,10 @@ PHP_METHOD(Phalcon_Mvc_Model_Resultset_Simple, toArray){
phalcon_fast_count(row_count, records TSRMLS_CC);
phalcon_update_property_this(this_ptr, SL("_count"), row_count TSRMLS_CC);
}
+ else {
+ PHALCON_INIT_NVAR(records);
+ array_init(records);
+ }
}
}
|
After changes and build of changes, it still doesn't work. |
Did you build Phalcon from ext/ or from build/? If from build/, please build it from ext/: cd ext
phpize
./configure
make
sudo make install If from ext/, could you please attach a test case reproducing the issue? |
Aww! I built it from build/, sorry about that. I just did what the part http://docs.phalconphp.com/en/latest/reference/install.html#compilation is describing. Build from ext/ it works fine. You fixed it. :) |
Phalcon\Mvc\Model\Resultset\Simple::toArray() method gives wrong result if empty.
It returns a correct array if not empty, and null if empty instead of an empty array (array()).
Here is the doc associated to the interface Phalcon\Mvc\Model\ResultsetInterface :
Returns a complete resultset as an array, if the resultset has a big number of rows
it could consume more memory than currently it does.
@return array
public function toArray();
The text was updated successfully, but these errors were encountered: