PDO Execute Query Function execute query database operation using GOModel

Description

GOModel execute query function provides a way to execute any type of query. It is specifically designed to handle queries if you are not able to run it using other script functions available. While using this, you can still use the PDO Data binding feature by specifying ? in place of value and passing value as array. Execute query takes first parameter as query and second parameter is optional where you can speficy value.

Function Defination

  
                                void function executeQuery($sql, $values = array());
                                

Parameters Details

Details Type Example
$sql - Query to be executed string Any valid query e.g. "select * from tablename"

Examples

  
                                $GOModel = new GOModel(); //create object of the GOModel class
                                $GOModel->connect("localhost", "root", "", "database");//connect to database
                                /* Execute Query function */
                                $records = $GOModel->executeQuery("select * from `emp`");                                
                            

More Examples

 
                                //Example 1
                                $result =  $GOModel->executeQuery("select * from emp where empId = ?", array(39));
                            

Result/Output

Array will be returned in case of select queries else records will be insert/updated/deleted depending upon query.

Debug

Option Details Example
$GOModel->getLastQuery(); Return last query executed select * from emp where empId = ?
print_r($GOModel->error) Print errors (if any)
$GOModel->totalRows; Total rows returned for select query 10