Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top