Mysqli Execute Query Operation

Description

Executes any mysql query and returns the result array(in case of select query). Use this for running any other queries that can't be run using the other select,insert,update,delete 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 "
parameter_values array Optional Value of parameters/columns passed parameter values are like array("Editor","Client")

Examples

  
         <?php 
         $sdb= new SimplifiedDB(); 
         $sdb->dbConnect("localhost","username","password","dbuser");
         $query="insert into user_roles (`role_name`,`role_description`) values(?,?)";
         $sdb->parameter_types="ss";
         $sdb->dbExecuteQuery($query,array("manager","manages user")); 
         ?> 

Result

It will insert a new row in above example.In case of select query, returns the result set .

Debuging

Debug Operation Result/Output
$sdb->query insert into user_roles (`role_name`,`role_description`) values(?,?)
$sdb->last_insert_id 30
$sdb->rows_affected 1
$sdb->message_info Connected to database
$sdb->error_info

More Example

  
          <?php 
          // Example of running query without using parameter binding 
          $sdb= new SimplifiedDB(); 
          $sdb->dbConnect("localhost","username","password","dbuser");
          $query="insert into user_roles (`role_name`,`role_description`) values('editor','edit posts')";
          $sdb->dbExecuteQuery($query); 
 		 ?>