PHP Classes

PDO MySQL database: Execute common MySQL queries 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: 606 All time: 5,160 This week: 206Up
Version License PHP version Categories
pdo-mysql-database 1Artistic License5.0.2PHP 5, Databases
Description 

Author

This class can execute common MySQL queries using PDO.

It can connect to a MySQL database using the PDO extension and executes common queries given the respective SQL statements.

Currently it executes SQL SELECT, INSERT, DELETE, UPDATE queries, as well return the result row count of a given SELECT query.

Picture of pedram marandi
Name: pedram marandi <contact>
Classes: 2 packages by
Country: Iran Iran

Example

<?php

// Eima
require_once('database.php');


// Delete query from database
$db->delete_pdo('DELETE FROM user WHERE id=2');
// insert into database
$data = array('pedram','123456');
$db->insert_pdo("INSERT INTO user (user, pass) VALUES(?, ?)", $data);
//update PDO
$data=array('Eima','2014');
$db->update_pdo('UPDATE user SET `user`=?, `pass`=?',$data);
//select table
$db->select_pdo("SELECT * FROM user");
foreach(
$db->result as $value) {
echo
$value['user'] . "<br/>";
}
//row count
$db->rowCount_pdo("SELECT * FROM user");
echo
$db->result;

// You can use this object to close your connection
// $db->close_pdo();
?>


Details

Developed by Eima you can use this code to learn how it work

  Files folder image Files (4)  
File Role Description
Files folder imagePDOdatabase (3 files)
Plain text file readme Data about class

  Files folder image Files (4)  /  PDOdatabase  
File Role Description
  Plain text file database.php Class about class
  Plain text file database.sql Data example database
  Plain text file example.php Example Class example

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:606
This week:0
All time:5,160
This week:206Up
User Comments (1)
it was really good :) Thx i really used it
10 years ago (amir reza Tahani)
70%StarStarStarStar