문제

i want to quote the values in a Where clause, Is this code a possible use of place holders?

 $where = "(user_id = ? AND company_id = ? AND color_id = ?)";  
 $values = array($userId, $companyId, $colorId);

 function qouteWhere($where, $values){
      foreach($values as $value)
           $where = $this->adapter->getPlatform()->quoteValue($value);

      return $where;  
 }

I appreciate any help. Thanks.

도움이 되었습니까?

해결책

You do not need to quote values.

$where = new Zend\Db\Sql\Where();

$where->equalTo('user_id', $userId);
$where->equalTo('company_id ', $companyId);
$where->equalTo('color_id ', $colorId);

This way it is much more secure against SQL injection because of use prepared statements.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top