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

PHQL and columnMap

Hi all. I have trouble with PHQL.

    $di->set('modelsManager', function() {
        return new Phalcon\Mvc\Model\Manager();
    });
    namespace Models;
    class Person extends \Phalcon\Mvc\Model{
        //indicate public variables
        ....
        public $inviteId;

        ....

        //indicate columnMap

        public function columnMap()
    {
        return [
            //another key => value of table
            'invite_id' => 'inviteId',
        ];
    }

    }

And when I try do this


        $phql = "Update \Models\Person SET inviteId = ?0 where email = ?1";
        $params = array(
            0 => 'BxvQ7aIbmRV',
            1 => '[email protected]',
        );

        $result = \Phalcon\DI::getDefault()->getModelsManager()->executeQuery($phql,$params);

        var_dump($result->success());//return TRUE but records not updated      

After this - records not updated,

but when i changed inviteId to invite_id in columnMap() - records updated.


    public function columnMap()
    {
        return [
        //another key => value of table
        'invite_id' => 'invite_id',
        ];
    }
    $phql = "Update \Models\Person SET invite_id = ?0 where email = ?1";
    $params = array(
        0 => 'BxvQ7aIbmRV',
        1 => '[email protected]',
    );
    $result = \Phalcon\DI::getDefault()->getModelsManager()->executeQuery($phql,$params);
    var_dump($result->success());//return TRUE  and record updated

What trouble with columnMap() ?

Hi @phalcon, do You have any ideas ?



58.4k

Hey

I see document support ORM not support PHQL , link here https://docs.phalcon.io/en/latest/reference/models.html#independent-column-mapping

Create a issue feature for it