PHP Classes

PHP PDO database class: Access databases using PDO

Recommend this page to a friend!
  Info   Documentation   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 59%Total: 1,519 All time: 2,580 This week: 49Up
Version License PHP version Categories
php-database-class 4.1.5MIT/X Consortium ...5.3.0PHP 5, Databases
Description 

Author

This class can access databases using PDO.

It uses the singleton pattern to establish a single database connection to a given database using PDO and executes several types of operations to store and retrieve information in that database.

Currently it can execute execute arbitrary or action queries composed from parameters that are included in prepared statements.

The class can also composed and execute queries to INSERT, UPDATE, DELETE records, or get the first or last rows of a SELECT query.

Picture of mohammad anzawi
  Performance   Level  
Name: mohammad anzawi <contact>
Classes: 8 packages by
Country: Jordan Jordan
Age: 10
All time rank: 14322 in Jordan Jordan
Week rank: 136 Up1 in Jordan Jordan Up
Innovation award
Innovation award
Nominee: 2x

Recommendations

What is the best PHP mssql pagination class?
Example mssql pagination with php

Documentation

PDO Database Class

A database class which uses the PDO extension. * Allows one connection with the database and deny duplicate connection, * this speeds up to use the database and reduces the load on the server. * supports many drivers (mysql, sqlite, PostgreSQL, mssql, sybase, Oracle Call Interface -oci-)

If you have any issue please open issue to fix it.

any suggestions would you like added or modified write to us at <m.anzawi2013@gmail.com>

install via composer

composer require phptricks/database_class

{
    "require": {
        "phptricks/database_class": "^5.0"
    }
}

Create First Migration :

php phptricks migrate:make UsersTable create -table=users

Migrate Tables :

php phptricks migrate

Create First Model :

php phptricks model UserModel --table=users

results :

use PHPtricks\Orm\Model;
class UserModel extends Model
{
    protected $_table = 'users';
}

Select All Data :

$user = new UserModel();
$allUsers = $user->select();

Insert Data :

$user = new UsersModel();
$user->insert([
    'username' => 'al-anzawi',
    'email' => 'm.anzawi2013@gmail.com'
]);

Full Documentation :

PHPtricks-ORM Full Documentation

Change Log :

5.0.0

  • ADD : Modeling System
  • ADD : Migrations
  • ADD : Commands-line
  • ADD : Joins [Models Relation]
  • ADD : `groupBy()` method
  • ADD : `toJsonFormatted()` method
  • ADD : `drop()` method - to delete tables
  • MODIFY : Database Class
  • MODIFY : `toArray()` Method

> please note: version 5.0.0 not compatible with old versions. > if you using PHPtricks-ORM v4.x.x or older in your project and you want to upgrade to v5.0.0, > you need to change a lot of things to meet new version.

4.1.0

  • ADD : `parseWhere(array $cons, $type = "AND")` method
  • ADD : `lastInsertedId()` method
  • ADD : `createOrUpdate($values, $conditionColumn = [])` method
  • ADD : `findBy($column, $value)` method
  • REMOVE: `empty()` method

4.0.0

  • MODIFY : namespace to `PHPtricks\Orm`
  • MODIFY : files structure

3.1.0

  • FIX : Duplicate connection
  • ADD : Some methods * `each()` -> to each all collection values * `map()` -> to map all results * `all()` -> to get all results * `last()` -> to get last selected record * `filter()` -> to filter values * `keys()` -> to get collection keys * `toJson()` -> to convert results to json format
  • ADD : convert results to json format when use collection as string automatically

3.0.0

  • ADD : direct update functionality
  • FIX : `dataView` method with first method
  • MODIFY : methods chaining technique * `select`, `first`, `find`, `paginate` NOW return Database Object * but you can use results as array or object * any time you can add `->results()` to convert to array or object

2.1.0

  • Add : pagination functionality
  • Add : count method
  • Add : `dataView` method (to display 'selected results' in a table)
  • FIX : `in()` method
  • FIX : `notIn()` method

2.0.0

  • ADD : supports multi `drivers` * mysql * PostgreSQL * sqlite * msSql * sybase * Oracle Call Interface (OCI)
  • ADD : multi where
  • ADD : type of where
  • ADD : show query
  • FIX : default constraint
  • ADD : limit function
  • ADD : offset function
  • rebuilt 80% of methods
  • change License terms

1.1.0

  • ADD Some Data Definition Language (DDL) functions. * ADD Create New Table * ADD Drop Table * ADD Alter Table * ADD new Column * Change Column Name * Drop Column * Rename Column

1.0.1

  • FIX: `first()` method to compatible with PHP V +5.3.0

1.0.0

  • First Release

  Files folder image Files (43)  
File Role Description
Files folder imageConfig (2 files)
Files folder imagephptricksORM (4 files, 8 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file index.php Aux. Auxiliary script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phptricks Example Example script
Accessible without login Plain text file README.md Doc. README.md

  Files folder image Files (43)  /  Config  
File Role Description
  Accessible without login Plain text file config_function.php Aux. Auxiliary script
  Accessible without login Plain text file database_config.php Aux. Auxiliary script

  Files folder image Files (43)  /  phptricksORM  
File Role Description
Files folder imageCollection (1 file)
Files folder imageCommand (8 files, 2 directories)
Files folder imageDDL (4 files)
Files folder imageDML (6 files)
Files folder imageFaker (1 file)
Files folder imageOperations (5 files)
Files folder imageProviders (1 file)
Files folder imageRelation (1 file)
  Accessible without login Plain text file Builder.php Class Class source
  Accessible without login Plain text file Database.php Class Class source
  Accessible without login Plain text file Model.php Class Class source
  Accessible without login Plain text file Variables.php Class Class source

  Files folder image Files (43)  /  phptricksORM  /  Collection  
File Role Description
  Accessible without login Plain text file Collection.php Class Class source

  Files folder image Files (43)  /  phptricksORM  /  Command  
File Role Description
Files folder imageConfig (1 file)
Files folder imageTemplates (4 files)
  Accessible without login Plain text file Alter.php Class Class source
  Accessible without login Plain text file Clear.php Class Class source
  Accessible without login Plain text file CommandHelpers.php Class Class source
  Accessible without login Plain text file Create.php Class Class source
  Accessible without login Plain text file Drop.php Class Class source
  Accessible without login Plain text file Make.php Class Class source
  Accessible without login Plain text file Migrate.php Class Class source
  Accessible without login Plain text file Model.php Class Class source

  Files folder image Files (43)  /  phptricksORM  /  Command  /  Config  
File Role Description
  Accessible without login Plain text file GetConfig.php Class Class source

  Files folder image Files (43)  /  phptricksORM  /  Command  /  Templates  
File Role Description
  Accessible without login Plain text file alter.template Class Class source
  Accessible without login Plain text file create.template Class Class source
  Accessible without login Plain text file drop.template Class Class source
  Accessible without login Plain text file model.template Class Class source

  Files folder image Files (43)  /  phptricksORM  /  DDL  
File Role Description
  Accessible without login Plain text file Alter.php Class Class source
  Accessible without login Plain text file Base.php Class Class source
  Accessible without login Plain text file Create.php Class Class source
  Accessible without login Plain text file Vars.php Class Class source

  Files folder image Files (43)  /  phptricksORM  /  DML  
File Role Description
  Accessible without login Plain text file Delete.php Class Class source
  Accessible without login Plain text file Insert.php Class Class source
  Accessible without login Plain text file Paginate.php Class Class source
  Accessible without login Plain text file Query.php Class Class source
  Accessible without login Plain text file Update.php Class Class source
  Accessible without login Plain text file Vars.php Class Class source

  Files folder image Files (43)  /  phptricksORM  /  Faker  
File Role Description
  Accessible without login Plain text file Faker.php Aux. Auxiliary script

  Files folder image Files (43)  /  phptricksORM  /  Operations  
File Role Description
  Accessible without login Plain text file Cond.php Class Class source
  Accessible without login Plain text file Operations.php Class Class source
  Accessible without login Plain text file Other.php Class Class source
  Accessible without login Plain text file parseWhere.php Class Class source
  Accessible without login Plain text file Where.php Class Class source

  Files folder image Files (43)  /  phptricksORM  /  Providers  
File Role Description
  Accessible without login Plain text file Provider.php Class Class source

  Files folder image Files (43)  /  phptricksORM  /  Relation  
File Role Description
  Accessible without login Plain text file RelationProvider.php Class Class source

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:1,519
This week:0
All time:2,580
This week:49Up
 User Ratings  
 
 All time
Utility:85%StarStarStarStarStar
Consistency:80%StarStarStarStarStar
Documentation:85%StarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:59%StarStarStar
Rank:1379