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

QueryBuilder does not give desire results

$qBuilder = \Phalcon\Di::getDefault()->get('modelsManager')->createBuilder();

    $qBuilder
        ->columns('c.customer_id')
        ->addFrom(NS\Models\Customer', 'c');

    $records = $qBuilder->getQuery()
        ->execute()->toArray();
    $intermediate = $qBuilder->getQuery()->parse();
    $dialect      = \Phalcon\DI::getDefault()->get('db')->getDialect();
    //echo  $sql          = $dialect->select($intermediate);
     print_r($records);

     it always return 4 results.

     I printed the SQL "SELECT `c`.`customer_id` AS `customer_id` FROM `oc_customer` AS `c` ", it gives 1228 when I run in PHPMYADMIN

     Using phalcon 2.0.9, Xampp on window

     Appericiate if someone can give me any clue on that.


5.4k
Accepted
answer

All is working well, I was on wrong DB :-(