phalcon/cphalcon — pull request #2424 by alkana (2014-05-12 18:48:54+00:00)
Title: Fix valid function for the first call

Hello,

Problem : the function valid respond false the first time when the fetchAll must be done.

Solution : set directly rows field after the fetch.

Example to reproduce :

#1 Create table
CREATE TABLE IF NOT EXISTS `user` (
`user_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`email` varchar(70) CHARACTER SET utf8 NOT NULL,
`password` char(32) CHARACTER SET utf8 NOT NULL,
PRIMARY KEY (`user_id`),
UNIQUE KEY `email_password` (`email`,`password`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=3 ;

INSERT INTO `user` (`user_id`, `email`, `password`) VALUES
(1, 'example1@gmail.com', 'pass1'),
(2, 'example2@test.com', 'pass2');

#2 (use scaffold of phalcon-devtool)
phalcon scaffold --table-name user

#3 Search all result (juste enter in http://127.0.0.1/user/index page
or check like this :
$users = User::find();
while ($users->valid() !== false) {
echo "user : " . $users->current()->email . '
';
}