PHP Classes

File: example/result_demo.php

Recommend this page to a friend!
  Classes of Slawomir Kaleta   Dframe Database   example/result_demo.php   Download  
File: example/result_demo.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Dframe Database
Access a MySQL database using PDO
Author: By
Last change: Update of example/result_demo.php
Date: 2 years ago
Size: 917 bytes


Class file image Download

// include pdo helper class to use common methods
require_once '../src/Helper/PDOHelper.php';
// include pdo class wrapper
require_once '../src/class.pdowrapper.php';

// database connection setings
$dbConfig = ['host' => 'localhost', 'dbname' => 'sampledb', 'username' => 'root', 'password' => ''];
// get instance of PDO Wrapper object
$db = new PdoWrapper($dbConfig);

// get instance of PDO Helper object
$helper = new PDOHelper();

// set error log mode true to show error on screen or false to log in log file

// select query with limit
$q = $db->pdoQuery('select * from customers;')->results();
// print array result

// select query with limit
$q = $db->pdoQuery('select * from customers;')->results('xml');
// print xml result
echo $q;

// select query with limit
$q = $db->pdoQuery('select * from customers;')->results('json');
// print json result
echo $q;