PHP Classes

File: examples/example.php

Recommend this page to a friend!
  Classes of Unay Santisteban   Database PDO Abstract Layer   examples/example.php   Download  
File: examples/example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Database PDO Abstract Layer
Run queries with PDO and get results in XML, JSON
Author: By
Last change: Update of examples/example.php
Date: 7 months ago
Size: 592 bytes
 

Contents

Class file image Download
<?php

require_once "../autoload.php";

$db = new OtherCode\Database\Database();

try {

   
$db->addConnection(array(
       
'driver' => 'mysql',
       
'host' => 'localhost',
       
'dbname' => 'test',
       
'username' => 'root',
       
'password' => 'root'
   
));

   
$query = $db->getQuery();
   
$query->select();
   
$query->from('ts_users');
   
$query->where('name', '=', ':name');

   
$db->setQuery($query);
   
$db->execute(array(':name' => 'Walter'));

   
$result = $db->loadObject();

   
var_dump($result);

} catch (\
Exception $e) {

    print
$e->getMessage();

}