Access to undeclared static property:$_connection on >3.2.12
Expected and Actual Behavior
Describe what you are trying to achieve and what goes wrong. Fetching record from table. Works on 3.2.12.
Provide output if related
PHP Fatal error: Uncaught Error: Access to undeclared static property: NewMigration_101::$_connection in /var/www/html/test-api/app/migrations/1.0.1/new.php:80
Provide minimal script to reproduce the issue
if (!self::$_connection->fetchOne(
"SELECT * FROM test WHERE name LIKE :name",
\Phalcon\Db::FETCH_ASSOC,
[
"name" => $name,
])) {
Details
-
System info and versions (if possible): (
phalcon info) Phalcon DevTools (3.4.0) Environment: OS: Linux 6801fde352f6 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64 PHP Version: 7.0.27-1+ubuntu16.04.1+deb.sury.org+1 PHP SAPI: cli PHP Bin: /usr/bin/php7.0 PHP Extension Dir: /usr/lib/php/20151012 PHP Bin Dir: /usr/bin Loaded PHP config: /etc/php/7.0/cli/php.ini Versions: Phalcon DevTools Version: 3.4.0 Phalcon Version: 3.3.1 AdminLTE Version: 2.3.6 -
Phalcon Framework version: (
php --ri phalcon) Version => 3.3.1 -
PHP Version: (
php -v) PHP 7.0.27-1 -
Operating System: Linux version 4.9.0-6-amd64 ([email protected]) (gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1) ) #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02)
-
Server: Nginx | Apache | Other Server version: Apache/2.4.18 (Ubuntu)
@k1T4eR Could you provide a bit more information, steps to reproduce?
Right. There is no $_connection parameter. To create a sql query to the database you'll need to create or get pdo connection.
Has this changed, though? I am able to run migrations just fine with devtools 3.2.11 but the same migrations using devtools 3.4.0 gives errors such as:
PHP Fatal error: Uncaught Error: Access to undeclared static property: AccountAbilitiesMigration_113::$_connection in /vagrant/service/identity/migrations/1.1.3/account_abilities.php:19
Stack trace:
#0 /home/vagrant/phalcon-devtools/scripts/Phalcon/Mvc/Model/Migration.php(488): AccountAbilitiesMigration_113->up()
#1 /home/vagrant/phalcon-devtools/scripts/Phalcon/Migrations.php(297): Phalcon\Mvc\Model\Migration::migrate(Object(Phalcon\Version\IncrementalItem), Object(Phalcon\Version\IncrementalItem), 'account_abiliti...')
#2 /home/vagrant/phalcon-devtools/scripts/Phalcon/Commands/Builtin/Migration.php(143): Phalcon\Migrations::run(Array)
#3 /home/vagrant/phalcon-devtools/scripts/Phalcon/Script.php(117): Phalcon\Commands\Builtin\Migration->run(Array)
#4 /home/vagrant/phalcon-devtools/scripts/Phalcon/Script.php(151): Phalcon\Script->dispatch(Object(Phalcon\Commands\Builtin\Migration))
#5 /home/vagrant/phalcon-devtools/phalcon.php(76): Phalcon\Script->run()
#6 {main}
thrown in /vagrant/service/identity/migrations/1.1.3/account_abilities.php on line 19
So I wouldn't outright claim it's not a bug because it was working but now is not. If it was never meant to work then perhaps document how people need to migrate their migrations so that they continue to work as expected. (Or if it's already documented, point us in the right direction?)
in 3.4 found ... they has renamed =) in migration self::$connection->query("SELECT * FROM subscriptions")->fetchAll();
in 3.4 found ... they has renamed =) in migration self::$connection->query("SELECT * FROM subscriptions")->fetchAll();
Correct, thanks.