New:Introducing Socket Scanning for VS Code Marketplace Extensions.Learn more →
Get Started

adilab/quick-pdo

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

adilab/quick-pdo

Adi PDO handler

Source
Packagist
Version
v1.0.3
Version published
Total downloads
48
Maintainers
1
Created
Source

Adi PDO handler

Allows to work with PDO faster and more convenient way.

Installing

Preferred way to install is with Composer.

Install this library using composer:

$ composer require adilab/quick-pdo

Configuration:

 /**
 * config/adi/databases.php
 */ 

return array(
	'db1' => array(

		'dsn' => 'mysql:host=127.0.0.1;dbname=db1;charset=utf8',
		'user' => 'db1',
		'pass' => '********',
	),
	'db2' => array(

		'dsn' => 'mysql:host=127.0.0.1;dbname=db2;charset=utf8',
		'user' => 'db2',
		'pass' => '********',
	),	
);


Usage:

require('vendor/autoload.php');

use Adi\QuickPDO\DB;

// Usage fetch() method
foreach (DB::main()->fetch('SELECT * FROM my_table WHERE my_column > ?', 10) as $row) {

	var_dump($row);
} 

// Usage row() method
var_dump(DB::alias('db2')->row("SELECT * FROM my_table WHERE my_column = ?", 2));

// Usage value() method
if (DB::alias('db1')->value("SELECT count(*) > 1 FROM my_table")) {

	echo 'There are many records.';
}

// Usage insert() method
DB::main()->insert('my_table', array('my_column1' => 'a', 'my_column2' => 'b'));

// Usage update() method
DB::main()->update('my_table', array('my_column1' => 'a', 'my_column2' => 'b'), new Where('id > ? AND id < ? OR id = ?', array(10,20,30)));
DB::main()->update('my_table', array('my_column1' => 'a', 'my_column2' => 'b'), array('id' => 25));

FAQs

Package last updated on 12 Mar 2016

Related posts