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

ORM can not bind parameters

I executed the following PHP code
class PublicController extends Controller{
    public function testAction(){
        $conditions = "nickname = :name: ";
        $parameters = array(
            "name" => "Robotina",
        );
        $robots = AdminMember::find(
            array(
                $conditions,
                "bind" => $parameters
            )
        );
    }
}

Here is my monitor SQL statement

[Wed, 17 Aug 16 14:24:38 +0000][INFO] SELECT IF(COUNT(*) > 0, 1, 0) FROM `INFORMATION_SCHEMA`.`TABLES` WHERE `TABLE_NAME` = 'admin_member' AND `TABLE_SCHEMA` = DATABASE()
[Wed, 17 Aug 16 14:24:38 +0000][INFO] DESCRIBE `admin_member`
[Wed, 17 Aug 16 14:24:38 +0000][INFO] SELECT `admin_member`.`id`, `admin_member`.`nickname`, `admin_member`.`username`, `admin_member`.`password`, `admin_member`.`status`, `admin_member`.`created_at`, `admin_member`.`updated_at` FROM `admin_member` WHERE `admin_member`.`nickname` = :name

Why parameter binding does not take effect?

Thank you!


85.5k
class PublicController extends Controller {

        public function testAction() {

            $conditions = "nickname = ?0 AND banned = ?1 AND top = ?2";
            $parameters = array(0 => "Robotina", 1 => 0 , 2 => "whatver value for top");
            $robots = AdminMember::find(array($conditions, "bind" => $parameters));
        }
    }


3.5k
Accepted
answer
edited Aug '16
Thank you very much, I've got it.
class PublicController extends Controller {

       public function testAction() {

           $conditions = "nickname = ?0 AND banned = ?1 AND top = ?2";
           $parameters = array(0 => "Robotina", 1 => 0 , 2 => "whatver value for top");
           $robots = AdminMember::find(array($conditions, "bind" => $parameters));
       }
   }

What you mean it does not take effect ?

SELECT `admin_member`.`id`, `admin_member`.`nickname`, `admin_member`.`username`, `admin_member`.`password`, `admin_member`.`status`, `admin_member`.`created_at`, `admin_member`.`updated_at` FROM `admin_member` WHERE `admin_member`.`nickname` = :name

I see :name here

Phalcon just logs PDO statements, not real sql statements.