We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

DevTools model generation is very slow

Hi,

I am using the latest 3.x DevTools with Phalcon 3.1.2 and Wamp on Windows 7 64bit platform. The system has 3Gb RAM of which at least 1Gb is unused most of the time. The model generation takes a lot of time on using either of the methods - Scaffold or Model. The below code is the culprit. This code takes about 2.5 to 3 minutes for each table. I wanted to know if there is something wrong with my setup and if not, then can this be improved. This code seems to be generating foreign key references. This code is approximately on lines 241 to 262 of Model.php.

foreach ($db->listTables() as $tableName) {
    foreach ($db->describeReferences($tableName, $schema) as $reference) {
        if ($reference->getReferencedTable() != $this->options->get('name')) {
            continue;
        }

        $entityNamespace = '';
        if ($this->options->contains('namespace')) {
            $entityNamespace = $this->options->get('namespace')."\\";
        }

        $refColumns = $reference->getReferencedColumns();
        $columns = $reference->getColumns();
        $initialize[] = $this->snippet->getRelation(
            'hasMany',
            $this->options->get('camelize') ? Utils::lowerCamelize($refColumns[0]) : $refColumns[0],
            $entityNamespace . Utils::camelize($tableName),
            $this->options->get('camelize') ? Utils::lowerCamelize($columns[0]) : $columns[0],
            "['alias' => '" . Utils::camelize($tableName) . "']"
        );
    }
}

Thanks, Amal



1.1k
Accepted
answer
edited Aug '17