phpsqloracle-databasezend-frameworkzend-db

How to add escape $ in Zend framework query


I need to add escape '$' in zend framework.

expected query:

SELECT * FROM V_HOME_SEARCH sv WHERE sv.NAME LIKE '%gar$_%' ESCAPE '$'

I tried this:

public function selectData($str){
  $select = $this->select();
  $select->setIntegrityCheck(false);
  $select->from(array('sv' => 'V_HOME_SEARCH'));
  $select->where('sv.NAME like (?)', '%'.strtolower($str).'%'); 
  $result = $this->fetchAll($select);
}

Here how can I add escape '$' in above code.

Thanks in advance


Solution

  • Zend_Db doesn't seem to offer any support for Oracle LIKE clauses with the ESCAPE keyword so all you can do is literally add it to the where() call

    $select->where("sv.NAME LIKE (?) ESCAPE '$'", '%' . strtolower($str) . '%');