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

Column:BIND_PARAM_INT still a string

Phalcon version 2.0.9.

Code:

<?php
                $user = Users::findFirst(
                    [
                        'columns'    => ['user_id'],
                        'conditions' => 'user_id = :user_id:',
                        'bind'       => ['user_id' => 7],
                        'bindTypes'  => [Column::BIND_PARAM_INT],
                    ]
                );

Gives this SQL:

SELECT `T_USERS`.`user_id` AS `user_id` FROM `T_USERS` WHERE `T_USERS`.`user_id` = '7' LIMIT 1

which is wrong, it should be (number 7, not string 7):

SELECT `T_USERS`.`user_id` AS `user_id` FROM `T_USERS` WHERE `T_USERS`.`user_id` = 7 LIMIT 1

What am I doing wrong? user_id is correct data_type in the database (int).

edited Feb '16

Try:

'bindTypes' => [
    'user_id' => Column::BIND_PARAM_INT
]


12.2k

Unfortunately, I tried that, but it's not working.

Anyone who uses BIND_PARAM_INT can confirm their sql code is correct (binding to int, not string)?