Tutorial :Doctrine Update by DQL + field with parenthesis: “(” and “)”


I have a doctrine update query to save my data:

$customer = Doctrine_Query::create()


->set('fax',"'". $this->getRequest()->getParam('fax')."'")

->where('id ='.$this->getRequest()->getParam('id'))


The problem is that the field fax has parenthesis and doctrine returns an error in the query because of these parenthesis "(" and ")".

Somebody knows a solution for this? Thank's


$customer = Doctrine_Query::create()      ->update('Customer')      ->set('fax', '?', $this->getRequest()->getParam('fax'))      ->where('id = ?', $this->getRequest()->getParam('id'))      ->execute();  


Not familiar with Doctrine, but what if you escape the parenthesis?

$fax = $this->getRequest()->getParam('fax');  $fax = str_replace(array('(',')'), array('\(','\)'), $fax);    // ...  ->set('fax',"'". $fax ."'");

Edit, and it might also be good to sanitize the input to only include numbers, parenthesis and maybe dashes:

// replace everything not 0-9, (, ) or - with nothing  $fax = preg_replace('/[^0-9\(\)\-]/','',$fax);

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »