We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
orm.cast_on_hydrate
Error when Phalcon\Mvc\Model::cloneResultMapHydrate() create result array.
Phalcon\Mvc\Model::cloneResultMapHydrate()
Option orm.castOnHydrate = true change generated column map structure in Phalcon\Mvc\Model\Query::_executeSelect() - (https://github.com/phalcon/cphalcon/blob/v3.0.1/phalcon/mvc/model/query.zep#L2781), but Phalcon\Mvc\Model::cloneResultMapHydrate() expects to string values in column map (https://github.com/phalcon/cphalcon/blob/v3.0.1/phalcon/mvc/model.zep#L653)
orm.castOnHydrate = true
Phalcon\Mvc\Model\Query::_executeSelect()
Actual:
PHP Warning: Illegal offset type in /var/www/hydrate/test.php on line 34 PHP Stack trace: PHP 1. {main}() /var/www/apiV2/test.php:0 PHP 2. Phalcon\Mvc\Model\Resultset->getFirst() /var/www/hydrate/test.php:34 PHP 3. Phalcon\Mvc\Model\Resultset\Simple->current() /var/www/hydrate/test.php:34 PHP 4. Phalcon\Mvc\Model::cloneResultMapHydrate() /var/www/hydrate/test.php:0 Array ( )
Expected:
Array ( [id] => 1 )
Robot.php
<?php namespace Test; use Phalcon\Mvc\Model; /** * Class Robot * * @author Andrey Dembitskiy * @package Test */ class Robot extends Model { public $id; /** * @inheritDoc */ public function getSource() { return 'Robot'; } }
test.php
<?php require 'Robot.php'; \Phalcon\Mvc\Model::setup(['castOnHydrate' => true]); $di = new \Phalcon\Di\FactoryDefault(); $di->set('db', function () { $descriptor = [ 'adapter' => 'Mysql', 'host' => 'localhost', 'port' => 3306, 'dbname' => 'phalcon_hydrate', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'options' => [PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'] ]; return new \Phalcon\Db\Adapter\Pdo\Mysql($descriptor); }); \Phalcon\Di::setDefault($di); /** @var \Phalcon\Mvc\Model\Query\BuilderInterface $builder */ $builder = $di->get('modelsManager')->createBuilder(); // The same problem with \Phalcon\Mvc\Model\Resultset::HYDRATE_OBJECTS $result = \Test\Robot::find() ->setHydrateMode(\Phalcon\Mvc\Model\Resultset::HYDRATE_ARRAYS); // PHP Warning: Illegal offset type in /var/www/hydrate/test.php on line 34 // PHP Stack trace: // PHP 1. {main}() /var/www/apiV2/test.php:0 // PHP 2. Phalcon\Mvc\Model\Resultset->getFirst() /var/www/hydrate/test.php:34 // PHP 3. Phalcon\Mvc\Model\Resultset\Simple->current() /var/www/hydrate/test.php:34 // PHP 4. Phalcon\Mvc\Model::cloneResultMapHydrate() /var/www/hydrate/test.php:0 $row = $result->getFirst(); // Shows `[]`, expected ['id' => '1'] print_r($row);
SQL
CREATE TABLE `phalcon_hydrate`.`Robot` ( `id` int(11) NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `phalcon_hydrate`.`Robot` (`id`) VALUES ('1'); INSERT INTO `phalcon_hydrate`.`Robot` (`id`) VALUES ('2'); INSERT INTO `phalcon_hydrate`.`Robot` (`id`) VALUES ('3'); INSERT INTO `phalcon_hydrate`.`Robot` (`id`) VALUES ('4');
The text was updated successfully, but these errors were encountered:
Phalcon\Mvc\Model::cloneResultMapHydrate
Merge pull request #12192 from andrew-demb/3.0.x
d369efd
Fixed #12191 not standard column map in `Phalcon\Mvc\Model::cloneResultMapHydrate`
Fixed in the 3.0.x branch.
3.0.x
Sorry, something went wrong.
No branches or pull requests
Description
Error when
Phalcon\Mvc\Model::cloneResultMapHydrate()
create result array.Option
orm.castOnHydrate = true
change generated column map structure inPhalcon\Mvc\Model\Query::_executeSelect()
- (https://github.com/phalcon/cphalcon/blob/v3.0.1/phalcon/mvc/model/query.zep#L2781), butPhalcon\Mvc\Model::cloneResultMapHydrate()
expects to string values in column map (https://github.com/phalcon/cphalcon/blob/v3.0.1/phalcon/mvc/model.zep#L653)Output
Actual:
Expected:
Scripts
Robot.php
test.php
SQL
Details
The text was updated successfully, but these errors were encountered: