Handle Quotes In MySQL Query Using Zend Framework

When a value that needs to be inserted into database, contains a mix of   ‘ and ”  , problem will arise with normal MySQL query.

We can handle the situation when using plain PHP with this solution.

But if we are using Zend Framework the solution will be –

$db = Zend_Db::factory(‘PDO_MYSQL’, $params);
$sql = “Insert Into table_name (key, value) Values (“.$db->quote($valueWithQuotes) .”)”;
$result = $db->query($sql);

Leave a comment

Your email address will not be published. Required fields are marked *