mezon / pdocrud
Simple PDO wrapper
Installs: 10 563
Dependents: 3
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: >=7.2.0
- mezon/conf: 1.2.*
Requires (Dev)
- infection/infection: ^0.21.5
- phpunit/phpunit: ^9.5
- vimeo/psalm: ^4.2
- dev-master
- 1.6.0
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0.x-dev
- 1.3.0
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
This package is auto-updated.
Last update: 2024-11-12 11:01:23 UTC
README
Intro
Mezon built-in classes support varios databases using PDO extension of the PHP language.
Detail
The following databases are supported:
- CUBRID
- MS SQL Server
- Firebird
- IBM
- Informix
- MySQL
- MS SQL Server
- Oracle
- ODBC and DB2
- PostgreSQL
- SQLite
- 4D
PDO objects are wrapped with ProCrud class wich will help you to create simple CRUD routine.
For example:
$dataConnection = [ 'dns' => 'mysql:host=localhost;dbname=testdb' , 'user' => 'user' , 'password' => 'password' ]; $crud = new \Mezon\PdoCrud\PdoCrud(); $crud->connect( $dataConnection ); // fetching fields id and title from table test_table where ids are greater than 12 $crud->prepare('SELECT * FROM test_table WHERE id > :id'); // result stores array of anonimous object $result = $crud->execSelect(['id' => '12']);
Deleting records
Deleting routine is quite simple:
$crud->delete( 'table_name' , // table name 'id > 10' , // WHERE statement 10 // number of records to delete );
Inserting records
Inserting routine is also very simple:
$crud->insert( 'table_name' , // table name [ 'f1' => 1 , f2 => '2' ] // new values for fields f1 and f2 );
Updating records
Updating routine is also very simple:
$crud->update( 'table_name' , // table name [ 'f1' => 1 , f2 => '2' ] , // new values for fields f1 and f2 'id > 10' // WHERE statement );
Transaction and thread safety
You can lock tables and work with transactions.
$crud->lockTables( [ 'table1' , 'table2' ] , [ 'READ' , 'WRITE' ] ); $crud->startTransaction(); // perform some changes in database // then commit these changes $crud->commit(); // or rollback them // $crud->commit(); $crud->unlockTables();