예제 #1
0
파일: example.php 프로젝트: rancoud/RQuery
<?php

require '../src/autoload.php';
$rQueryConf = new RQueryConfiguratorDatabase('mysql', 'localhost', 'root', '', 'rquery');
$rQuery = new RQuery($rQueryConf, new RQueryDriverPdo());
$rQuery->dropTable("test");
$rQuery->dropTable(["test", "toto"]);
$rQuery->useSqlFile('test_file.sql');
$rQuery->dropTable("test");
$rQuery->dropTable(["test", "toto"]);
$rQuery->exec("CREATE TABLE `test` (\n  `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,\n  `name` VARCHAR(255) NOT NULL,\n  PRIMARY KEY (`id`) );");
$rQuery->optimize("test");
$rQuery->optimize(["test", "toto"]);
$id = $rQuery->insert("INSERT INTO test (`name`) VALUES (:name)", array('name' => 'A'));
var_dump("Insert Into test last id: " . $id);
$idB = $rQuery->insert("INSERT INTO test (`name`) VALUES (:name)", array('name' => 'B'));
var_dump("Insert Into test last id: " . $idB);
$id = $rQuery->insert("INSERT INTO test (`name`) VALUES (:name)", array('name' => 'C'));
var_dump("Insert Into test last id: " . $id);
$id = $rQuery->insert("INSERT INTO test (`name`) VALUES (:name)", array('name' => 'chickenskill'));
var_dump("Insert Into test last id: " . $id);
$rowsAffected = $rQuery->update("UPDATE test SET name = :name WHERE id = :id", array('id' => $idB, 'name' => 'google'));
var_dump("Row affected: " . $rowsAffected);
$rowsAffected = $rQuery->delete("DELETE FROM test WHERE name = :name1 OR name = :name2", array('name1' => 'A', 'name2' => 'C'));
var_dump("Row affected: " . $rowsAffected);
$cursor = $rQuery->select("SELECT * FROM test");
while ($row = $rQuery->read($cursor)) {
    var_dump($row);
}
$pdo = $rQuery->getDriver();
var_dump($pdo);