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

could not find driver

Hi there,

When tryint to execute $trades = Trades::findFirst(1); I get the error 'could not find driver'

Which is odd to me, when I try to execute $exchange = Exchanges::findFirst(["name = '" . $this->config->exchange . "' AND active"]); it works perfectly.

This is my php-m list:

[PHP Modules] calendar Core ctype curl date dom exif fileinfo filter ftp gd gearman gettext hash iconv intl json libxml mbstring msgpack mysqli mysqlnd openssl pcntl pcre PDO pdo_mysql phalcon Phar posix readline Reflection session shmop SimpleXML sockets sodium SPL standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlwriter xsl Zend OPcache zip zlib

[Zend Modules] Zend OPcache

When I uncomment this part of the code it all suddenly works: but I do need the part..

$this->log = new \Monolog\Logger('trades-model'); $this->log->pushHandler(new \PDOHandler(new \PDO( getenv('DB_CONNECTION').':host='.getenv('DB_HOST').';dbname='.getenv('DB_DATABASE'), getenv('DB_USERNAME'), getenv('DB_PASSWORD') )));

Hi mpjraaij I recomend you don't use this Trades::findFirst(1); use insteand

$trades = Trades::findFirst([
    'conditions' => 'id = {id:int}',
    'bind' => [
        'id' => 1

This method cache the query builder and get better performance. Good luck

That definitely does help. How can I make this query cache?

        $phql = "SELECT id
                    FROM Trades
                    WHERE Trades.rule_id = :rule_id:
                    AND Trades.exchange_id = :exchange_id:
                    AND Trades.active 
                    AND Trades.trade
                    AND Trades.deleted_at IS NULL
                    AND EXISTS(SELECT *
                        FROM Users
                        WHERE Trades.user_id = Users.id
                        AND NOT EXISTS (SELECT * 
                            FROM Subscriptions
                            WHERE Users.id = Subscriptions.user_id
                            AND stripe_plan = :plan:

        $trades = $this->modelsManager->executeQuery($phql, [
            'rule_id'       => $rule,
            'exchange_id'   => $exchange,
            'plan'          =>  'free',

You have to use createQuery like this

$query = $this->modelsManager->createQuery($phql);

$trades = $query->execute([
    'rule_id'           => $rule,
    'exchange_id' => $exchange,
    'plan'               =>  'free',

Thanks! Seems like it is cached already then as it's not lowering the execution speed :)