PHP Classes

PHP PDO database class: Access databases using PDO

Recommend this page to a friend!
  Info   View files Documentation   View files View files (43)   DownloadInstall with Composer Download .zip   Reputation   Support forum (5)   Blog (1)    
Last Updated Ratings Unique User Downloads Download Rankings
2022-10-21 (23 days ago) RSS 2.0 feedStarStarStarStar 65%Total: 1,495 This week: 11All time: 2,613 This week: 44Up
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.

Recommendations

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

Picture of mohammad anzawi
  Performance   Level  
Name: mohammad anzawi <contact>
Classes: 8 packages by
Country: Jordan Jordan
Innovation award
Innovation award
Nominee: 2x

Details

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  
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  /  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  /  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  /  phptricksORM  /  Collection  
File Role Description
  Accessible without login Plain text file Collection.php Class Class source

  Files folder image Files  /  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  /  phptricksORM  /  Command  /  Config  
File Role Description
  Accessible without login Plain text file GetConfig.php Class Class source

  Files folder image Files  /  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  /  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  /  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  /  phptricksORM  /  Faker  
File Role Description
  Accessible without login Plain text file Faker.php Aux. Auxiliary script

  Files folder image Files  /  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  /  phptricksORM  /  Providers  
File Role Description
  Accessible without login Plain text file Provider.php Class Class source

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

 Version Control Unique User Downloads Download Rankings  
 100%
Total:1,495
This week:11
All time:2,613
This week:44Up
 User Ratings  
 
 All time
Utility:93%StarStarStarStarStar
Consistency:87%StarStarStarStarStar
Documentation:93%StarStarStarStarStar
Examples:-
Tests:-
Videos:-
Overall:65%StarStarStarStar
Rank:833
  
For more information send a message to info at phpclasses dot org.