PHP Classes

PDO Connect and Query: Connect and query database 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 yet rated by the usersTotal: 302 All time: 7,398 This week: 206Up
Version License PHP version Categories
pdo-connect-query 1.0.0The PHP License5PHP 5, Databases
Description 

Author

This class can connect and query database using PDO.

It can connect to a database using PDO and executes SQL queries in different ways. Currently it can:

- Execute common or prepares queries and return results into arrays
- Execute queries and return the number of result rows
- Get a limited number of records from a table
- Perform inner join queries

Picture of Chike Jibunoh
Name: Chike Jibunoh <contact>
Classes: 2 packages by
Country: Nigeria Nigeria

Example

<?php
//This is just an example of the usage, not really a working application
include('dbclass.php');
$db = new Db;
if(
$db){
$email = trim($_POST['email']);
$username = trim($_POST['username']);
$firstname = trim($_POST['firstname']);
$lastname = trim($_POST['lastname']);

$reg = $db_conn->query("INSERT INTO example(firstname,lastname,username,password,email,date_reg) VALUES(:username,:password,:email,:privi,Now())", array(
   
'email' => $email,
   
'username' => $username,
   
'password' => $password,
   
'privi' => $privi));
}


Details

myprojects


  Files folder image Files (3)  
File Role Description
Plain text file dbclass.php Class Class source
Accessible without login Plain text file dbclassexample.php Example Example script
Accessible without login Plain text file README.md Data Auxiliary data

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:302
This week:0
All time:7,398
This week:206Up