Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Dmitriy Bulgar  >  DP_Access_MySQL_database  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example using class
Class: DP_Access_MySQL_database
MySQL database access wrapper
Author: By
Last change: 0.2
Date: 4 years ago
Size: 1,135 bytes
 

Contents

Class file image Download
<?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>";

 
?>