-
-
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
[2.0.4 bug] Cannot use a scalar value as an array #10648
Labels
need script to reproduce
Script is required to reproduce the issue
Comments
@andresgutierrez look here: https://github.com/phalcon/cphalcon/blob/master/phalcon/mvc/model/resultset/simple.zep#L205 if !fetch renamedKey, renamedKey[0] { throw new Exception("Column '" . key . "' is not part of the column map"); } let renamed[renamedKey[0]] = value; We replace renamedKey by its first item but them ask for the first item of renamedKey... It must be let renamed[renamedKey] = value; Same for the other notice. |
Usecase: <?php
$di = new Phalcon\DI();
$di['db'] = new Phalcon\Db\Adapter\Pdo\MySQL([
"host" => "localhost",
"username" => "phalcon_test",
"password" => "phalcon_test",
"dbname" => "phalcon_test",
]);
\Phalcon\Mvc\Model::setup(['castOnHydrate' => true]);
$di['modelsManager'] = new Phalcon\Mvc\Model\Manager();
$di['modelsManager']->setDi($di);
$di['modelsMetadata'] = new Phalcon\Mvc\Model\MetaData\Memory();
class Robot extends Phalcon\Mvc\Model
{
public $id;
}
$q = new Phalcon\Mvc\Model\Query('select * from Robot limit 1', $di);
$r = $q->execute();
var_dump($r->toArray()); Result:
|
Fixed in the 2.0.x branch |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using PHP 5.6.8 and getting the below notices when I have error reporting turned on.
It looks like the way an array is written as another array's key is the cause.
// Notice: Cannot use a scalar value as an array in phalcon/mvc/model/resultset/simple.zep on line 209
let renamed[renamedKey[0]] = value;
// Notice: Cannot use a scalar value as an array in phalcon/mvc/model.zep on line 3600
let snapshot[attribute[0]] = value;
The text was updated successfully, but these errors were encountered: