The code below receives a query and may only execute it when the query contains ‘INSERT’ or ‘UPDATE’. But when I feed it ‘INSERT INTO test_table (id, test_value) VALUES (1, ‘Test’)’, it raises the ‘requires an Update or Insert query’.
What am I missing?
public function setQuery($query)
{
if(strpos($query, 'INSERT') === false && strpos($query, 'UPDATE') === false ) {
trigger_error('Method [' . __FUNCTION__ . '] requires an Update or Insert query [Q: '.$query.']');
exit;
}
$this->_queries++;
mysql_query($query);
$this->_result = mysql_insert_id();
if(!$this->_result) {
trigger_error('Method [' . __FUNCTION__ . '] failed [Q: '.$query.']');
}
return $this->_result;
}
Maybe someone send you ‘insert’? Try stripos 🙂