2013-08-02 50 views
0

散落在整個Magento的,你可以找到類似神祕的SQL二進制運算符=:在Magento

 $select->joinLeft(
      array('c' => $couponTable), 
      'c.customer_id=root.entity_id AND c.rule_id=:rule_id', 
      array('c.coupon_id') 
     ); 

結構是什麼二元運算=:呢?

+1

它不是二元運算符的這個變量 –

回答

2

這是準備聲明的一部分。看看PDO's prepare

<?php 
/* Execute a prepared statement by passing an array of values */ 
$sql = 'SELECT name, colour, calories 
    FROM fruit 
    WHERE calories < :calories AND colour = :colour'; 
$sth = $dbh->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY)); 
$sth->execute(array(':calories' => 150, ':colour' => 'red')); 
$red = $sth->fetchAll(); 
$sth->execute(array(':calories' => 175, ':colour' => 'yellow')); 
$yellow = $sth->fetchAll(); 
?> 

所以別的地方它是結合一個值,該變量...像

$select->execute(array(":rule_id" => "someValue")); 
4

=:不是運營商。運營商只有=,它檢查是否相等。 :rule_id是一個標識符,準備好的SQL語句用它來引用一個參數。請參閱準備好的聲明以獲取更多信