PDO Execute Query Operation

Description

Executes any mysql query and returns the result (returns array in case of select query). Use this for running complex queries that can't be run using the other select,insert,update,delete,join functions

Function Reference :
mixed dbExecuteQuery(string $query [, array $parameter_values=array()]) 

Parameters

Name Type Required Parameter Info Example
query string Yes Query to be executed $query="select firstName,lastName,email from users where gender='?'"
parameter_values array Optional Array with values of columns in query(pass column values as parameter values to use binding) e.g. array("male");

Examples

 
            <?php             
            $sdb= new SimplifiedDB();
            $sdb->dbConnect("localhost","username","password","dbuser"); 
            $query="select firstName,lastName,email from users where gender=?";
            $sdb->dbExecuteQuery($query,array("male")); 
            ?> 

Result

Executes the query.You can use this function to execute very complex queries like queries using varibles,multiple select statement in one query etc.
If query is select operation then it will return output in associative array(default). You can change it using Fetch mode as explained in previous select operations.

Debuging

Debug Operation Result/Output
$sdb->query select firstName,lastName,email from users where gender=?
$sdb->last_insert_id
$sdb->rows_affected
$sdb->message_info Connected to database
$sdb->error_info

More Examples

 
            <?php            
            $query="select firstName,lastName,email from users where gender=? and role_id=?";
            $parameter_values=array("male","10");
            $result=$sdb->dbExecuteQuery($query,$parameter_values); 
			?>