Handling non-SELECT queries


show more Handling non-SELECT queries provides you with in-depth training on Developer. Taught by David Powers as part of the Accessing Databases with Object-Oriented PHP show less
please wait ...

Handling non-SELECT queries

With MySQL improved the query method handles all SQL statements, not just select queries. Let's take a look at using the query method to insert and delete records and to find out how many records have been affected in the database. This is mysql_insert.php which you can find in the chapter five 05_06 folder of the exercise files. This file contains a simple insert query. The insert saying, new value into the names table.

So to insert that, what we need to do is to call the query method on the database object. So it's DB. Query and pass it the SQL. When used with a select statement, the Query Method returns MySQLi result object. But with Insert, Update, Replace or Delete, it simply returns true or false depending on whether it's succeeded or failed. Will be looking at getting error messages later, but we can get a useful piece of information from the database connection object immediately after executing a non select query.

The number of rows effected is stored as the effected rows property. S...

Handling non-SELECT queries
Video duration: 5m 27s 3h 47m Intermediate

Viewers:

Handling non-SELECT queries provides you with in-depth training on Developer. Taught by David Powers as part of the Accessing Databases with Object-Oriented PHP

Subject:
Developer
Software:
PHP
Author:
please wait ...