PHP Classes

File: public_html/example.php

Recommend this page to a friend!
  Classes of Kakhaber Kashmadze   DbUtils   public_html/example.php   Download  
File: public_html/example.php
Role: Example script
Content type: text/plain
Description: Example script
Class: DbUtils
Access and Manage MySQL, PostgreSQL or MS SQL
Author: By
Last change: example and readme
Date: 6 years ago
Size: 888 bytes
 

Contents

Class file image Download
<?php
# Example for class DbUtils\Db
# Writen By Kakhaber Kashmadze <info@soft.ge>

#for this example use test-mysql.sql from folder ../sql/

use DbUtils\Db;
use
DbUtils\Helper\HelperDb;

define('INCLUDE_DIR',dirname(dirname(__FILE__)).'/include');
define('CLASSES_DIR',INCLUDE_DIR.'/classes');

require_once
'params.php';

$dbMapper=new DbMapper(array(
   
'type'=>'mysql',
   
'host'=>DBHOST,
   
'name'=>DBNAME,
   
'user'=>DBUSER,
   
'password'=>DBPASS,
   
'port'=>3306
));

Db::init($dbMapper->getDbparams(), $dbMapper->getDb());

require_once
'include/classes/DbUtils/Db.php';
require_once
'include/classes/DbUtils/DbMapper.php';
require_once
'include/classes/DbUtils/Helper/HelperDb.php';


Db::init($dbMapper->getDbparams(), $dbMapper->getDb());


Retrieve one row from table users:

$row=Db::fetchRow("select lname, fname from users where id=1");
echo
$row['lname']." ".$row['fname']."\n";

?>