PHP Classes

File: example_mysql.php

Recommend this page to a friend!
  Classes of Itay Segal   PDO DB Connector   example_mysql.php   Download  
File: example_mysql.php
Role: Example script
Content type: text/plain
Description: example for mysql usage
Class: PDO DB Connector
Connect and execute common queries using PDO
Author: By
Last change:
Date: 7 years ago
Size: 843 bytes
 

Contents

Class file image Download
<?php
/**
 * Author: Itay Segal
 * This is usage example for mysql connector
 **/
include_once 'DBMethods.php';
$db = new DBMethods(true);

/**
 * Get All rows in table
 */
$result = $db->getMultipleRows('my_table');
echo
"<pre>";print_r($result);

/**
 * Insert new data into my_table
 */
$fields = array('field1','field2');
$values = array('Value1','Value2');
$result = $db->insertRecords($fields,$values,'my_table');
if(
$result){
    echo
'Data was added successfully';
}
else{
    echo
'There was an error, please check your log file';
}

/**
 * Update data in my_table
 */
$sets = array('field1=Value2','field2=Value1');
$result = $db->UpdateRecords('my_table',$sets,'id=1');
if(
$result){
    echo
'Data was updated successfully';
}
else{
    echo
'There was an error, please check your log file';
}