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

Help Plz!!Query\Builder Problem?

<?php $di = new \Phalcon\DI(); $db = new \Phalcon\Db\Adapter\Pdo\Mysql(array( 'hostname' => 'localhost', 'username' => 'root', 'password' => '123456', 'dbname' => 'coremvc' )); $eventsManager = new Phalcon\Events\Manager();

//Listen all the database events $eventsManager->attach('db', function($event, $connection){ if ($event->getType() == 'beforeQuery') { $sqlVariables = $connection->getSqlVariables(); if (count($sqlVariables)) { echo $connection->getSqlStatement(), ' [', join(', ', $sqlVariables), ']<br>'; } else { echo $connection->getSqlStatement(), '<br>'; } } });

//Assign the eventsManager to the db adapter instance $db->setEventsManager($eventsManager);

$di['db'] = $db; $di['modelsManager'] = new Phalcon\Mvc\Model\Manager(); $di['modelsMetadata'] = new Phalcon\Mvc\Model\MetaData\Memory();

//Define the class class Modules extends Phalcon\Mvc\Model {

} $modules = $di['modelsManager'] ->createBuilder() ->from('Modules') ->inWhere('moduleid',array(1,2)) ->getQuery() ->execute();

foreach ($modules as $module) { echo $module->parentid, ' ', $module->title, '<br>'; / This row ouput nothing / }


The table Modules have 2 rows. moduleid parentid title 1 0 System 2 1 Config

but output is empty

output is empty

SELECT IF(COUNT(*)>0, 1 , 0) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='modules' DESCRIBE modules SELECT modules.moduleid, modules.parentid, modules.title FROM modules WHERE modules.moduleid IN (:phi0, :phi1) [1, 2]

Apache 2.4.4 + php 5.3.25 + phalcon 1.1.0

and when i used nginx, the method named with inWhere() will be crash, FASTCGI ERROR



98.9k


12.8k

oh,i'm terrible sorry. can u help me ?



98.9k

Are you using windows? The DLLs were compiled again today, can you check with them?

However, I've tested with nginx today and I can't see problem



12.8k

can u give me a copy of nginx configuration file? And i want to know your server env. for nginx version,php version and platform verion ex:centos x64 or 32bits



12.8k

I had dowloaded the new DLLs but the IIS was crashed yet. ENV: WIN7 x64 + IIS 7.5 + PHP 5.4.0-NTS-32bit + Phalcon 1.1.0-PHP-5.4.0-nts-32bit DLL

Error: FastCgiModule 0x000000ff



98.9k

I think I found the problem, I'm looking for a solution, from now, you can alternatively use:

$modules = $di['modelsManager']
 ->createBuilder()
 ->from('Modules')
 ->where('moduleid IN (?0, ?1)', array(1, 2))
->getQuery()
->execute();


12.8k

This is right,but the method names of inWhere can not be use.Is that a bug?



98.9k

Just added a fix for this in the master branch for inWhere, can you please compile and try again?



12.8k

ok,thank u very much! do u have msn account?



98.9k

I don't have msn, but you can add me to Gmail chat: [email protected]