magicBind() public method

Like bind(), but adds some magic: - a=? becomes a IS NULL if passed null - a!=? or a<>? becomes a IS NOT NULL if passed null - a=? becomes a IN (1, 2, 3) if passed array(1, 2, 3) - a!=? or a<>? becomes a NOT IN (1, 2, 3) if passed array(1, 2, 3)
public magicBind ( $sql, array $params = [] ) : string
$params array
return string
Example #1
0
 public function testBindWithBackquote()
 {
     $binder = new Binder();
     $this->assertEquals($binder->magicBind('`id`=?', array(1)), "`id`='1'");
 }
Example #2
0
 /**
  * Binds an array of parameters into a string
  * @return string
  */
 public function bind($sql, $params = array())
 {
     $binder = new Binder();
     return $binder->magicBind($sql, (array) $params);
 }
Example #3
0
 /**
  * Convenience method for orderBy, to be consistent with where and andWhere.
  * @chainable
  */
 public function andOrderBy($sql, $params = array())
 {
     $binder = new Binder();
     $this->_order[] = $binder->magicBind($sql, (array) $params);
     return $this;
 }