<?php require "../src/Database/TSQLQueryBuilderBasic.php"; require "../src/Database/CDatabaseBasic.php"; $db = new \Mos\Database\CDatabaseBasic(); // // Create a table // $db->setTablePrefix('mos_'); $db->createTable('test', ['id' => ['integer', 'primary key', 'not null'], 'age' => ['integer'], 'text' => ['varchar(20)'], 'text2' => ['varchar(20)']]); echo "<pre>" . $db->getSQL() . "</pre>"; // // Insert a single row into table using key => value // $db->insert('test', ['id' => 2, 'text' => "Mumintrollet", 'text2' => "Mumindalen"]); echo "<pre>" . $db->getSQL() . "</pre>"; // // Insert a single row into table using two arrays // $db->insert('test', ['id', 'text', 'text2'], [2, "Mumintrollet", "Mumindalen"]); echo "<pre>" . $db->getSQL() . "</pre>"; // // Insert a single row into table using one array (rest will be sent as parameters) // $db->insert('test', ['id', 'text', 'text2']); echo "<pre>" . $db->getSQL() . "</pre>"; // // Update a single row using key => value // $db->update('test', ['age' => 22, 'text' => "Mumintrollet", 'text2' => "Mumindalen"], "id = 2"); echo "<pre>" . $db->getSQL() . "</pre>";
// Do not buffer outputs, write directly // // Get required files // require "../../src/Database/TSQLQueryBuilderBasic.php"; require "../../src/Database/CDatabaseBasic.php"; $db = new \Mos\Database\CDatabaseBasic(); // // Read config file // $options = (require "../config_mysql.php"); // // Carry out som tests, db must exist // $db->setOptions($options); $db->setTablePrefix($options['table_prefix']); $db->connect(); // // Drop a table if it exists // $tableName = 'test'; $db->dropTableIfExists($tableName)->execute(); // // Create a table // $db->createTable($tableName, ['id' => ['integer', 'auto_increment', 'primary key', 'not null'], 'username' => ['varchar(20)'], 'password' => ['varchar(32)'], 'salt' => ['varchar(32)']])->execute(); // // Add some users to test with // $sql = <<<EOD INSERT INTO