PHP Classes

PDO Database class: Access SQL databases using PDO

Recommend this page to a friend!
     
  Info   Example   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: 1,004 All time: 3,638 This week: 206Up
Version License PHP version Categories
db-pdo-simple-class 1.0GNU General Publi...5.2PHP 5, Databases
Description 

Author

This package can access SQL databases using PDO.

There is a base configuration class that builds the database connection string.

The actual database access class is a sub-class that established the database connection using the PDO extension and executes SQL queries.

It can execute one or more INSERT or UPDATE queries using prepared statements, execute SELECT queries and return the whole result set into an array, and retrieve the number of records in a given table.

Picture of Assontia Patient
Name: Assontia Patient <contact>
Classes: 1 package by
Country: Cameroon Cameroon

Example

<?php
   
// change the values by yours
   
include('library/library.php');
   
$a = new db;
   
$a->table = 'site_colors'; // your table name
   
   
$records = $a->select("SELECT * FROM $a->table");
    echo
$a->count($a->table) . " records found!";
   
// records of a table
   
echo "<pre>";
    foreach(
$records as $r){
       
print_r($r);
    }
   
   
// refresh to see the effect of the insert
   
$a->insert("INSERT INTO $a->table(name, class) VALUES('Blink', 'blink');");
   
   
// other or all sql queries can be sent using
   
$a->sql('DELETE ....');
   
?>


  Files folder image Files (4)  
File Role Description
Files folder imageclasses (1 file)
Files folder imagelibrary (1 file)
Accessible without login Plain text file config.php Conf. Configure your database parameters
Accessible without login Plain text file test.php Example Test file to edit before launching

  Files folder image Files (4)  /  classes  
File Role Description
  Plain text file db.class.php Class Database class

  Files folder image Files (4)  /  library  
File Role Description
  Accessible without login Plain text file library.php Conf. Library of functions and globals

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:1,004
This week:0
All time:3,638
This week:206Up
User Comments (1)
In english please?
12 years ago (Vitaliy)
35%StarStar