Пример #1
0
<?php

/*
*
* @ Package: PDOx - Useful Query Builder & PDO Class
* @ Author: izni burak demirtas / @izniburak <*****@*****.**>
* @ Web: http://burakdemirtas.org
* @ URL: https://github.com/izniburak/PDOx
* @ Licence: The MIT License (MIT) - Copyright (c) - http://opensource.org/licenses/MIT
*
*/
require 'vendor/autoload.php';
// database config
$config = ['host' => 'localhost', 'driver' => 'mysql', 'database' => 'test', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => ''];
// start PDOx
$db = new \Buki\Pdox($config);
// Select Records
$records = $db->table('pages')->where('age', '>', 18)->orderBy('id', 'desc')->limit(10)->getAll();
var_dump($records);
Пример #2
0
<?php

require 'vendor/autoload.php';
$config = ['host' => 'localhost', 'driver' => 'mysql', 'database' => 'test', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => ''];
$db = new \Buki\Pdox($config);
$data = ['username' => 'new-user-name', 'password' => md5('new-password'), 'status' => 1];
$query = $db->table('users')->where('id', 17)->update($data);
if ($query) {
    echo 'Record updated!';
}
Пример #3
0
<?php

require 'vendor/autoload.php';
$config = ['host' => 'localhost', 'driver' => 'mysql', 'database' => 'test', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => ''];
$db = new \Buki\Pdox($config);
$records = $db->table('users')->select('name, surname, age')->where('age', '>', 18)->orderBy('id', 'desc')->limit(20)->getAll();
foreach ($records as $record) {
    echo $record->name . '<br />' . $record->surname . '<br />' . $record->age;
}
Пример #4
0
<?php

require 'vendor/autoload.php';
$config = ['host' => 'localhost', 'driver' => 'mysql', 'database' => 'test', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => ''];
$db = new \Buki\Pdox($config);
$query = $db->table('pages')->where('year', 2014)->where('status', 0)->delete();
if ($query) {
    echo 'Record(s) deleted!';
}
Пример #5
0
<?php

require 'vendor/autoload.php';
$config = ['host' => 'localhost', 'driver' => 'mysql', 'database' => 'test', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => ''];
$db = new \Buki\Pdox($config);
$records = $db->table('authors')->select('authors.name, articles.title, articles.slug')->join('articles', 'users.id', 'articles.user_id')->where('users.status', 1)->where('articles.status', 1)->orderBy('articles.created_at', 'desc')->limit(10)->getAll();
foreach ($records as $record) {
    echo $record->name . '<br />' . $record->title . '<br />' . $record->slug;
}
Пример #6
0
<?php

require 'vendor/autoload.php';
$config = ['host' => 'localhost', 'driver' => 'mysql', 'database' => 'test', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'collation' => 'utf8_general_ci', 'prefix' => ''];
$db = new \Buki\Pdox($config);
$data = ['name' => 'Burak', 'surname' => 'Demirtaş', 'age' => '24', 'country' => 'Turkey', 'city' => 'Ankara', 'status' => 1];
$query = $db->table('users')->insert($data);
if ($query) {
    echo 'Record added! <br />' . 'InsertID: ' . $db->insertId();
}