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

500 server error on incorrect number of array elements on single join in "joins" parameter

Hi.

When we use the "joins" parameter in the query builder and we do not add all 4 array elements (model class name, join contition, alias, join type), we get a 500 server error.

Example:

\Models\Articles::findFirst([
    'joins' => [
        [
            //'Models\Users',
            'author.id = [Models\Articles].fk_user',
            'author',
            'inner'
        ]
    ],
    'conditions' => '[Models\Articles].id = :id:',
    'bind' => [
        'id' => 1
    ]
]);

I comment/remove the "first" array element. In this case, i got server 500 error. If it happens that we do not add all 4 parameters for join, should not I get an exception?

Log from apache.log (fcgid mode):

[Tue Jun 05 09:18:29.419259 2018] [fcgid:warn] [pid 16508:tid 1240] (OS 109)The pipe has been terminated.  : [client 127.0.0.1:54502] mod_fcgid: get overlap result error, referer: https://localhost
[Tue Jun 05 09:18:29.419259 2018] [core:error] [pid 16508:tid 1240] [client 127.0.0.1:54502] End of script output before headers: index.php, referer: https://localhost

Apache handler mode:

[Tue Jun 05 09:53:31.356382 2018] [mpm_winnt:notice] [pid 4400:tid 760] AH00428: Parent: child process 3168 exited with status 255 -- Restarting.
[Tue Jun 05 09:53:31.435435 2018] [mpm_winnt:notice] [pid 4400:tid 760] AH00455: Apache/2.4.33 (Win64) PHP/7.2.4 configured -- resuming normal operations
[Tue Jun 05 09:53:31.435435 2018] [mpm_winnt:notice] [pid 4400:tid 760] AH00456: Apache Lounge VC15 Server built: Mar 18 2018 12:58:47
[Tue Jun 05 09:53:31.435435 2018] [core:notice] [pid 4400:tid 760] AH00094: Command line: 'w:\\wamp64\\bin\\apache\\apache2.4.33\\bin\\httpd.exe -d W:/wamp64/bin/apache/apache2.4.33'
[Tue Jun 05 09:53:31.439438 2018] [mpm_winnt:notice] [pid 4400:tid 760] AH00418: Parent: Created child process 13784
[Tue Jun 05 09:53:31.925442 2018] [mpm_winnt:notice] [pid 13784:tid 708] AH00354: Child: Starting 64 worker threads.
Environment:
  OS: Windows NT DESKTOP-XXXXXXX 10.0 build 16299 (Windows 10) AMD64
  PHP Version: 7.2.4
  PHP SAPI: cli
  PHP Bin: W:\wamp64\bin\php\php7.2.4\php.exe
  PHP Extension Dir: C:\php\ext
  PHP Bin Dir: C:\php
  Loaded PHP config: W:\wamp64\bin\php\php7.2.4\php.ini
Versions:
  Phalcon DevTools Version: 3.2.13
  Phalcon Version: 3.3.2
  AdminLTE Version: 2.3.6

Apache/2.4.33 (Win64) PHP/7.2.4 mod_fcgid/2.3.9 


85.5k

i think there is mysql error or syntax error or something like this. make sure error reporting is enabled

https://stackoverflow.com/questions/1053424/how-do-i-get-php-errors-to-display



85.5k

are you sure findFirst have an option to join ? first time i see it and docs doesn't say anything about it ?

perhaps you need modelsManager to do your query https://stackoverflow.com/questions/21715835/loading-models-with-inner-join

Well, Mr. Frankel, who started this program, began to suffer from the computer disease that anybody who works with computers now knows about. It's a very serious disease and it interferes completely with the work. The trouble with computers is you play with them.