PHP Classes

PDO database: Database access wrapper using PDO

Recommend this page to a friend!
     
  Info   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 550 All time: 5,512 This week: 96Up
Version License PHP version Categories
pdo-database-wrapper 1.3GNU General Publi...5.0PHP 5, Databases
Description 

Author

This class is a database access wrapper using PDO. It can:

- Connect to a given database server
- Execute SQL prepared queries using given parameters
- Return query results for SELECT like queries, or return the number of affected rows for other types of queries

Picture of Julio Alvarado
Name: Julio Alvarado <contact>
Classes: 1 package by
Country: United States United States

Details

/************************************************************************/ /* My Database Connection /* http:// /* Copyright © 2010 by Julio Alvarado /************************************************************************/ /* This program is free software. You can redistribute it and/or modify */ /* it under the terms of the GNU General Public License as published by */ /* the Free Software Foundation; either version 2 of the License. */ /************************************************************************/ How to connect: $DATABASE = array( "dsn" => "mysql:host=localhost;port=3306;dbname=mydb", "username" => "root", "password" => "password" ); $db = new db($DATABASE); if($db->connect()) { //Do Somthing }else{ die($db->error()); } Select, Insert, Update and delete Data: $data = $db->exec($sqlselectstatement, $fetchtype , $fetchstyle, $bindings); A: Sql statements: (required) "Select * from Mydb" "INSERT Mydb (name, status, description) VALUES (:name, :status, :description)"; "UPDATE Mydb SET name = :name, status = :status, description = :description WHERE id = :id"; "DELETE FROM Mydb WHERE id = :id"; B: Fetch Types: (optional) A: fetch B: fetchAll C: fetchColumn D: fetchObject C: Fetch Style: PDO::FETCH_ASSOC PDO::FETCH_BOTH (default) PDO::FETCH_BOUND PDO::FETCH_INTO PDO::FETCH_LAZY PDO::FETCH_NAMED PDO::FETCH_NUM PDO::FETCH_OBJ D: Bindings: (depending on statement) $bindings = array("name" => $name, "status" => $status, "description" => $description, "id" => $id); you can run diectly to execution(for no response back) only errors $data = $db->execution($sqlselectstatement, $bindings); other functions Rowcount: (gets row count for selection) $mycount = $db->rowcount($sql->Select); ColCount: (gets column count for selection) $mycount = $db->colcount($sql->Select); Close: (Closes Connection) $db->Close(); Error:(error catching) $db->error();

  Files folder image Files (2)  
File Role Description
Plain text file pdo_database.php Class PDO Database Class
Plain text file Readme.txt Doc. Readme

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  
 0%
Total:550
This week:0
All time:5,512
This week:96Up