0
votes

I have a doctrine update query to save my data:

$customer = Doctrine_Query::create()

->update('Customer')

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

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

->execute();

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

2

2 Answers

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

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);