Overview

Packages

  • objSQL

Documentation

  • objSQL Connection
  • objSQL Error Handling
  • General Queries
  • Prepared Statements
  • Transactions
  • Resultset Methods
  • Helper Method - Select Query
  • Helper Method - Update Query
  • Helper Method - Insert Query
  • Helper Method - Delete Query
  • Helper Method - Paging Query
  • Helper Method - Row Count Query
  • Utility Methods

Classes

    cubrid_connection
  • cubrid_prepare
  • cubrid_resultset
  • cubrid_statement
  • cubrid_transaction
  • mysql_connection
  • mysql_prepare
  • mysql_resultset
  • mysql_statement
  • mysql_transaction
  • obj_access
  • objSQL
  • pdo_connection
  • pdo_prepare
  • pdo_resultset
  • pdo_statement
  • pdo_transaction
  • pgsql_connection
  • pgsql_prepare
  • pgsql_resultset
  • pgsql_statement
  • pgsql_transaction
  • sqlite3_connection
  • sqlite3_prepare
  • sqlite3_resultset
  • sqlite3_statement
  • sqlite3_transaction
  • sqlsrv_connection
  • sqlsrv_prepare
  • sqlsrv_resultset
  • sqlsrv_statement
  • sqlsrv_transaction
  • Overview
  • Package
  • Class
  • Tree

objSQL Database Connection Instance

To connect to a database, create an objSQL() instance.

  • The database connection information can be entered as a comma delimited string or an array.
  • Database types are case-insensitive but must be entered as: cubrid, mysql, pgsql, sqlite3, sqlsrv or pdo:cubrid, pdo:mysql, pdo:pgsql, pdo:sqlite3, pdo:sqlsrv for PDO drivers. Enter mysql or pdo:mysql as the driver for MariaDB.
  • objSQL performs an internal validation before it attempts to connect to a database by verifying the database type. A failure triggers an error.

Returns: Connection resource/object or false on failure.

  • Call obj_close() to close the current connection instance.

Returns: True on success or false on failure.

<?php

/**

Drivers

CUBRID: cubrid or pdo:cubrid
MySQL/MariaDB: mysql or pdo:mysql
Postgres: pgsql or pdo:pgsql
SQLite3: sqlite3 or pdo:sqlite3
SQL Server: sqlsrv or pdo:sqlsrv


usage: str - $connection = "dbtype,localhost,username,password,database,port";
usage: array - $connection = array( "dbtype","localhost","username","password","database","port" );

*/

try
{
    
$dbh = new objSQL( "mysql,localhost,root,pass,mydb,3306" );
        
    if ( 
error_get_last() !== null )
        throw new 
Exception( error_get_last()['message'] );
        
    
//Query block  
    
    
$dbh->obj_close();    
}
catch ( 
Exception $e ) 
{
    echo 
$e->getMessage();
}


try
{
    
$dbh = new objSQL( "pdo:mysql,localhost,root,pass,mydb,3306" );
        
    if ( 
error_get_last() !== null )
        throw new 
Exception( error_get_last()['message'] );
        
    
//Query block  
    
    
$dbh->obj_close();    
}
catch ( 
Exception $e ) 
{
    echo 
$e->getMessage();
}

?>   

objSQL 3.2.0 API documentation generated by ApiGen 2.8.0

Documentation licensed under a Creative Commons Attribution 3.0 Unported License.