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

How to get bind params from a builder?

i found this property, but it not public:

https://github.com/phalcon/cphalcon/blob/9073ca32cd23c19f958cabd8373575a22db56d02/phalcon/mvc/model/query/builder.zep#L95

so, how can i get bind params from a builder?



85.5k
Accepted
answer
namespace whatever\Plugins\Query;

class Builder extends \Phalcon\Mvc\Model\Query\Builder {

    public function __construct($params = null, $di = null){
        parent::__construct($params, $di);
    }

    public function getBindParams(){

        return $this->_bindParams;
    }
}

and then you use your own class instead of Phalcon one



2.6k
edited Mar '18

finally, i use this code:

$class = new \ReflectionClass(get_class($builder));
$bindParams = $class->getProperty('_bindParams');
$bindParams->setAccessible(true);
$bind = $bindParams->getValue($builder);