$query1 = 'SELECT * FROM table WHERE field = ?';
$query2 = 'UPDATE table SET field = ?';
How can I detect if the query modifies the database, or just requests results from it?
Is it enough if I do a strpos for SELECT (if it’s found then query is read-only) ? Or are there other situations I need to handle?
Assuming it’s mysql ..
mysql_affected_rows()shows the number of rows that were affeced by an insert/delete/update etc whilstmysql_num_rows()shows you how many were selected. Depending on which function returns a value you should be able to determine the kind of response.