Example #1
0
<?php

// class file
require 'BasicDB.php';
// connection
$db = new \Erbilen\Database\BasicDB('localhost', 'testdb', 'testuser', 'password');
// delete
$query = $db->delete('users')->where('user_id', 2)->done();
if ($query) {
    echo 'user deleted';
}
Example #2
0
<?php

// class file
require 'BasicDB.php';
// connection
$db = new \Erbilen\Database\BasicDB('localhost', 'testdb', 'testuser', 'password');
// insert
$query = $db->insert('users')->set(array(username => 'test user', password => 123456, email => '*****@*****.**'));
if ($query) {
    echo 'Last Insert Id: ' . $db->lastId();
}
Example #3
0
<?php

// class file
require 'BasicDB.php';
// connection
$db = new \Erbilen\Database\BasicDB('localhost', 'testdb', 'testuser', 'password');
// select
$query = $db->select('post')->join('users', '%s.user_id = %s.post_userid', 'left')->where('post_approval', 1)->or_where('post_approval', 2)->orderby('post_id', 'desc')->groupby('post_user')->limit(0, 10)->run();
if ($query) {
    foreach ($query as $row) {
        print_r($row);
    }
}
Example #4
0
<?php

// class file
require 'BasicDB.php';
// connection
$db = new \Erbilen\Database\BasicDB('localhost', 'testdb', 'testuser', 'password');
// update
$query = $db->update('users')->where('user_id', 2)->set(array(username => 'another user'));
if ($query) {
    echo 'update success';
}
<?php

// class file
require 'BasicDB.php';
// connection
$db = new \Erbilen\Database\BasicDB('localhost', 'testdb', 'testuser', 'password');
// pagination example
$totalRecord = $db->select('users')->from('count(user_id) as total')->total();
$pageLimit = 4;
$pageParam = 'page';
$pagination = $db->pagination($totalRecord, $pageLimit, $pageParam);
$query = $db->select('users')->orderby('user_id', 'DESC')->limit($pagination['start'], $pagination['limit'])->run();
print_r($query);
echo $db->showPagination('http://localhost/test/?' . $pageParam . '=[page]');