コード例 #1
0
    goDead("Insert, fetch test failed.");
}
if (!isset($testData['name']) || !isset($testData['surname']) || !isset($testData['date'])) {
    goDead("Fetch data test failed.");
}
if ($testData['name'] != 'Archangel' || $testData['surname'] != 'Design' || $testData['date'] != '791') {
    goDead("fetchOne returned unexpected data.");
}
print "[OK] insert works fine.\n";
/**
 * ===== UPDATE TEST =====
 */
print "testing updates...\n";
$testData['surname'] = 'design';
unset($testData['id']);
$adb->updateRecords('users', $testData, 'name');
$testData = $adb->fetchOne('users', ['surname' => 'design']);
if (!$testData) {
    goDead('Update test failed.');
}
if ($testData['surname'] != 'design') {
    goDead("Update test failed.\n");
}
$adb->deleteRecords('users', [1 => 1]);
$adb->insert('users', ['name' => 'Archangel', 'date' => '1']);
$adb->insert('users', ['name' => 'Design', 'date' => '1']);
$adb->updateRecords('users', ['name' => 'theName', 'surname' => 'theSurname', 'date' => '1'], 'date');
$records = $adb->fetchAll('users');
if (count($records) !== 2) {
    goDead("update failed. Wrong amount of records returned.");
}
コード例 #2
0
<?php

/**
 * Archangel DB 2
 * www.archangel-design.com
 * @author Rafal Martinez-Marjanski
 */
require 'autoload_register.php';
$adb = new \ArchangelDB\ADB2();
$res = $adb->tableExists('users');
die;
$res = $adb->insert('users', ['name' => 'Pascal', 'surname' => 'Picolo', 'date' => 'now()']);
var_dump($adb->getLastQuery());
var_dump($adb->lastInsertId());
var_dump($adb->updateRecords('users', ['id' => 34, 'name' => 'Pascal', 'date' => '321321321']));
var_dump($adb->getLastQuery());
var_dump($adb->fetchAll('users'));