GOModel Database abstraction and helper class for PHP


GOModel is a PHP database abstraction and helper file for performing various database related operations like insert, delete, update, select without writing any sql queries.

You can perform complex database related operations without writing any queries at all.

Below is example how to write queries using GOModel

                                $/* create object of class */
                                $GOModel = new GOModel();

                                /* Connect to the datbase */
                                $GOModel->connect("localhost", "root", "", "database");

                                /* call GOModel function */
                                $result =  $GOModel->select("emp");


If you wanted to same using the traditional way then you would have been required to write following long code

                                    /*** mysql hostname ***/
                                    $hostname = 'localhost';

                                    /*** mysql username ***/
                                    $username = 'username';

                                    /*** mysql password ***/
                                    $password = 'password';

                                    try {

                                            /*** connect to database ***/
                                        $dbh = new PDO("mysql:host=$hostname;dbname=emp", $username, $password);

                                        /*** echo a message saying we have connected ***/
                                        echo 'Connected to database
'; /*** set the error reporting attribute ***/ $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); /*** some variables ***/ $animal_id = 6; $animal_name = 'bruce'; /*** prepare the SQL statement ***/ $stmt = $dbh->prepare("SELECT animal_id,animal_name FROM emp WHERE animal_id = :animal_id AND animal_name = :animal_name"); /*** bind the paramaters ***/ $stmt->bindParam(':animal_id', $animal_id, PDO::PARAM_INT); $stmt->bindParam(':animal_name', $animal_name, PDO::PARAM_STR, 5); /*** execute the prepared statement ***/ $stmt->execute(); /*** fetch the results ***/ $result = $stmt->fetchAll(); /*** loop of the results ***/ foreach($result as $row) { echo $row['animal_id'].'
'; echo $row['animal_name']; } /*** close the database connection ***/ $dbh = null; } catch(PDOException $e) { echo $e->getMessage(); } ?>


  • Perform Insert Operation using simple functions
  • Perform Update Operation using simple functions
  • Perform Delete Operation using simple functions
  • Perform Select Operation using simple functions
  • Multiple table join Operation using simple functions
  • Table related operations like get all tables from database, truncate table, delete table, rename table etc.
  • Subquery
  • Column based operation like getting all columns of table, primary key of table etc
  • Export functions to export data in CSV, PDF, Excel, HTML, XML Format
  • Helper functions like pagination, random password generation
  • Best practices using PDO with data binding
  • Support for PDO Transctions
  • Three different types of database support (Mysql, PGSql and SQLite)
  • Support for batch operations for insert, update and delete
  • Execute query directly
  • Various debugging options like get last query, get rows inserted, error messages etc
  • Support for order by, group by, like, between, in, not in, having etc
  • Well documented and demo codes to make things easier to understand
  • Perform complex queries with multiple use of “And” and “OR” keywords
  • Supports method chaining