Skip to content
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

Create one model take too long with Postgre #1319

Open
quickdunk opened this issue Sep 28, 2019 · 1 comment
Open

Create one model take too long with Postgre #1319

quickdunk opened this issue Sep 28, 2019 · 1 comment

Comments

@quickdunk
Copy link

quickdunk commented Sep 28, 2019

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: #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
  • Operating System: Pop!_OS 19.04
  • Server: Apache | Other
  • Other related info : Postgre database
@Jeckerson
Copy link
Member

Problem in Phalcon Adapter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

4 participants