PHP Classes

DP Access MySQL database: MySQL database access wrapper

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 261 All time: 7,797 This week: 455Up
Version License PHP version Categories
dp_mysql_driver 0.1GNU General Publi...5.0PHP 5, Databases
Description 

Author

This class implements a MySQL database access wrapper. It can:

- Establish MySQL database connection setting the preferred character encoding
- Execute SELECT, INSERT and UPDATE SQL queries from parameters that define tables, columns and values
- Retrieve query results into arrays or objects
- Retrieve the number columns in a query result

Picture of Dmitriy Bulgar
Name: Dmitriy Bulgar <contact>
Classes: 1 package by
Country: Moldova Moldova
Age: 35
All time rank: 39415 in Moldova Moldova
Week rank: 286 Up2 in Moldova Moldova Up

Example

<?php
include_once 'DP_mysql_driver.php';
$db = new DP_mysql_driver(DP_DB_SERVER,DP_DB_USERNAME,DP_DB_NAME,DP_DB_PASSWORD);


/**
 * using simple_query($sql)
 */
$res = $db->simple_query("SELECT * FROM `member` LIMIT 1");
echo
"simple_query(SELECT * FROM `member`)";
foreach(
$res as $v)
{
    echo
"<pre>";
   
print_r($v);
    echo
"</pre><br>";
}
echo
"SQL: ".$db->get_last_sql()."<hr>";
/**
 * using insert()
 */
$db->insert('member',array('name'=>'Dmitriy','lastname'=>'Bulgar'));
/**
 * show See the results function
 * And use the function get_insert_id(),get_record_by_id()
 */
$row = $db->get_record_by_id('member','id',$db->get_insert_id());
echo
"<pre>";
print_r($row);
echo
"SQL: ".$db->get_last_sql()."</pre><br><hr>";
/**
 * using update(), execute(),escape()
 */
$db->update('member',array('name'=>'DanxilL'),array('id'=>$db->get_insert_id(),'name'=>'Dmitriy'));
echo
"SQL: ".$db->get_last_sql();
$db->execute("SELECT `name` FROM `member` WHERE `name`=".$db->escape('DanxilL')." LIMIT 1");
echo
"<pre>";
print_r($db->fetch_row());
echo
"SQL: ".$db->get_last_sql()."</pre><br><hr>";

 
?>


  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example example using class
Plain text file DP_mysql_driver Class class.database DP_mysql_driver.php

 Version Control Unique User Downloads Download Rankings  
 0%
Total:261
This week:0
All time:7,797
This week:455Up