A PHP Error was encountered

Severity: 8192

Message: Return type of CI_Session_files_driver::open($save_path, $name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Filename: drivers/Session_files_driver.php

Line Number: 132

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Return type of CI_Session_files_driver::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Filename: drivers/Session_files_driver.php

Line Number: 290

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Return type of CI_Session_files_driver::read($session_id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Filename: drivers/Session_files_driver.php

Line Number: 164

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Return type of CI_Session_files_driver::write($session_id, $session_data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Filename: drivers/Session_files_driver.php

Line Number: 233

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Return type of CI_Session_files_driver::destroy($session_id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Filename: drivers/Session_files_driver.php

Line Number: 313

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Return type of CI_Session_files_driver::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice

Filename: drivers/Session_files_driver.php

Line Number: 354

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Session ini settings cannot be changed after headers have already been sent

Filename: Session/Session.php

Line Number: 284

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: session_set_cookie_params(): Session cookie parameters cannot be changed after headers have already been sent

Filename: Session/Session.php

Line Number: 291

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Session ini settings cannot be changed after headers have already been sent

Filename: Session/Session.php

Line Number: 306

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Session ini settings cannot be changed after headers have already been sent

Filename: Session/Session.php

Line Number: 316

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Session ini settings cannot be changed after headers have already been sent

Filename: Session/Session.php

Line Number: 317

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Session ini settings cannot be changed after headers have already been sent

Filename: Session/Session.php

Line Number: 318

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Session ini settings cannot be changed after headers have already been sent

Filename: Session/Session.php

Line Number: 319

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: ini_set(): Session ini settings cannot be changed after headers have already been sent

Filename: Session/Session.php

Line Number: 377

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: session_set_save_handler(): Session save handler cannot be changed after headers have already been sent

Filename: Session/Session.php

Line Number: 110

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: Warning

Message: session_start(): Session cannot be started after headers have already been sent

Filename: Session/Session.php

Line Number: 143

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Cache::$apc is deprecated

Filename: libraries/Driver.php

Line Number: 188

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/models/DefaultModel.php
Line: 8
Function: driver

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

A PHP Error was encountered

Severity: 8192

Message: Creation of dynamic property CI_Cache::$file is deprecated

Filename: libraries/Driver.php

Line Number: 188

Backtrace:

File: /home/palugada/domains/envato.palugada.top/public_html/application/models/DefaultModel.php
Line: 8
Function: driver

File: /home/palugada/domains/envato.palugada.top/public_html/application/core/MY_Controller.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/application/controllers/Codecanyon.php
Line: 6
Function: __construct

File: /home/palugada/domains/envato.palugada.top/public_html/index.php
Line: 315
Function: require_once

PDO CRUD Class | codecanyon

This small class will save you time by providing CRUD methods for quickly building SQL query statements. This can be used and integrated into any existing project with ease. Also, it is great at handling exceptions when SQL errors are produced.

System Requirements

  • PHP 5
  • PDO Extension
  • Supported PDO Driver(s) – PDO_SQLITE, PDO_MYSQL, PDO_PGSQL

Usage

require('class.db.php');

// Create
$bind = array( ":id" => $_POST['user_id'], ":user" => $_POST['username']);
db::inst()->insert( "users", array(":id", ":user"), 'user_id, username', $bind );

// Read
db::inst()->init( "SELECT * FROM users ORDER BY last_name" );

// Update
$bind = array( ":signature" => $_POST['signature'] );
db::inst()->update( 'users', array('signature' => ":signature"), array('username',$_SESSION['username']), $bind );

// Delete
$bind = array(":id" => $_POST['pID']);
db::inst()->delete( "posts", "postID = :id", $bind );

Changelog

  • (08.07.2013) v1.1
    • Emulation set to false for true PDO
    • Fixed issue when error reporting set to E_ALL
    • Added DSN_PREFIX instead of hardcoding the prefix for more flexibility
    • No need to double quote bind parameters anymore
    • Updated for PHP 5.4.x
    • Fixed query method to use bind parameters when not false
    • Updated documentation to reflect changes

You May Also Like