Example #1
0
<?php

include dirname(dirname(__FILE__)) . "/DATABASE.php";
include dirname(dirname(__FILE__)) . "/OPERATOR.php";
use Nise\Database\OPERATOR as E;
use Nise\Database\DATABASE;
$config = [];
$config['type'] = DATABASE::MYSQL;
$config['host'] = "localhost";
$config['db'] = "theworldwarriormc";
$config['user'] = "******";
$config['password'] = "******";
DATABASE::register_database("MYSQLDB", $config);
$users = E::MYSQLDB("users");
$blog = E::MYSQLDB("blog");
$blog_links = ["userid" => "users:id"];
// create links between the tables
$blog->addLinks($blog_links);
$blog->joinAdd($users);
// using the created links, create a join clause
$blog->selectAs($users, "u_%s");
// prefix the users table columns with "u_" to avoid ambiguous column names
while ($blog->fetch()) {
    print "\"" . $blog->subject . "\" by " . $blog->u_username . "<br>";
}
$users->type = 1;
$users->orderBy("id");
while ($users->fetch()) {
    print $users->id . ": " . $users->username . "<br>";
}
$users->id = 4;
Example #2
0
<?php

include dirname(dirname(__FILE__)) . "/DATABASE.php";
include dirname(dirname(__FILE__)) . "/OPERATOR.php";
use Nise\Database\OPERATOR as E;
use Nise\Database\DATABASE;
$config = [];
$config['type'] = DATABASE::SQLITE;
$config['host'] = "";
$config['db'] = "/tmp/testsqlite.db";
$config['user'] = "";
$config['password'] = "";
DATABASE::register_database("SQLITEDB", $config);
$users = E::MYSQLDB("users");
$blog = E::MYSQLDB("blog");
$blog_links = ["userid" => "users:id"];
// create links between the tables
$blog->addLinks($blog_links);
$blog->joinAdd($users);
// using the created links, create a join clause
$blog->selectAs($users, "u_%s");
// prefix the users table columns with "u_" to avoid ambiguous column names
while ($blog->fetch()) {
    print "\"" . $blog->subject . "\" by " . $blog->u_username . "<br>";
}
$users->type = 1;
$users->orderBy("id");
while ($users->fetch()) {
    print $users->id . ": " . $users->username . "<br>";
}
$users->id = 4;