Hi, I want to create one model using phalcon tools 3.4.0 with this command:
phalcon model seg_usuarios --namespace="App\Models" --get-set
In this particular case the database have many tables (more than 700) and when I try to execute take too long, so I explored the code and found the same issue reported and solved before: https://github.com/phalcon/phalcon-devtools/issues/821
I expected the model was created without any relationship unless I specified by command line.
I solved modifying:
Phalcon\Builder\Model.php
// line 212
$referenceList = $this->getReferenceList($schema, $table, $db);
// function getReferenceList
/**
* Get reference list from option
*
* @param string $schema
* @param string $table
* @param Pdo $db
* @return array
*/
protected function getReferenceList($schema, $table, Pdo $db)
{
if ($this->modelOptions->hasOption('referenceList')) {
return $this->modelOptions->getOption('referenceList');
}
$referenceList = [];
if (isset($referenceList[$table])) {
$referenceList = $referenceList[$table];
} else {
$referenceList[$table] = $db->describeReferences($table, $schema);
}
return $referenceList;
}
And I found the 'reference List' is not send by command line, so the if clause never return that value.
Details
System info and versions:
Environment: OS: Linux pop-os 5.0.0-21-generic #22+system76-Ubuntu SMP Tue Jul 16 19:57:52 UTC 2019 x86_64 PHP Version: 7.3.9-1+ubuntu19.04.1+deb.sury.org+1 PHP SAPI: cli PHP Bin: /usr/bin/php7.3 PHP Extension Dir: /usr/lib/php/20180731 PHP Bin Dir: /usr/bin Loaded PHP config: /etc/php/7.3/cli/php.ini Versions: Phalcon DevTools Version: 3.4.0 Phalcon Version: 3.4.4 AdminLTE Version: 2.3.6
Phalcon Framework version:
`phalcon
Web framework delivered as a C-extension for PHP
phalcon => enabled
Author => Phalcon Team and contributors
Version => 3.4.4
Build Date => Aug 8 2019 07:03:32
Powered by Zephir => Version 0.10.16-6826149172
Directive => Local Value => Master Value
phalcon.db.escape_identifiers => On => On
phalcon.db.force_casting => Off => Off
phalcon.orm.events => On => On
phalcon.orm.virtual_foreign_keys => On => On
phalcon.orm.column_renaming => On => On
phalcon.orm.not_null_validations => On => On
phalcon.orm.exception_on_failed_save => Off => Off
phalcon.orm.enable_literals => On => On
phalcon.orm.late_state_binding => Off => Off
phalcon.orm.enable_implicit_joins => On => On
phalcon.orm.cast_on_hydrate => Off => Off
phalcon.orm.ignore_unknown_columns => Off => Off
phalcon.orm.update_snapshot_on_save => On => On
phalcon.orm.disable_assign_setters => Off => Off`
PHP Version: PHP 7.3.9-1+ubuntu19.04.1+deb.sury.org+1 (cli) (built: Sep 2 2019 12:54:43) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.9-1+ubuntu19.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
I expected the model was created without any relationship unless I specified by command line.
I solved modifying: Phalcon\Builder\Model.php
And I found the 'reference List' is not send by command line, so the if clause never return that value.
Details
Environment: OS: Linux pop-os 5.0.0-21-generic #22+system76-Ubuntu SMP Tue Jul 16 19:57:52 UTC 2019 x86_64 PHP Version: 7.3.9-1+ubuntu19.04.1+deb.sury.org+1 PHP SAPI: cli PHP Bin: /usr/bin/php7.3 PHP Extension Dir: /usr/lib/php/20180731 PHP Bin Dir: /usr/bin Loaded PHP config: /etc/php/7.3/cli/php.ini Versions: Phalcon DevTools Version: 3.4.0 Phalcon Version: 3.4.4 AdminLTE Version: 2.3.6
Directive => Local Value => Master Value phalcon.db.escape_identifiers => On => On phalcon.db.force_casting => Off => Off phalcon.orm.events => On => On phalcon.orm.virtual_foreign_keys => On => On phalcon.orm.column_renaming => On => On phalcon.orm.not_null_validations => On => On phalcon.orm.exception_on_failed_save => Off => Off phalcon.orm.enable_literals => On => On phalcon.orm.late_state_binding => Off => Off phalcon.orm.enable_implicit_joins => On => On phalcon.orm.cast_on_hydrate => Off => Off phalcon.orm.ignore_unknown_columns => Off => Off phalcon.orm.update_snapshot_on_save => On => On phalcon.orm.disable_assign_setters => Off => Off`
PHP 7.3.9-1+ubuntu19.04.1+deb.sury.org+1 (cli) (built: Sep 2 2019 12:54:43) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.3.9, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.3.9-1+ubuntu19.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies