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."); } foreach ($records as $record) { if ($record['name'] !== 'theName' || $record['surname'] !== 'theSurname') { goDead("update failed. Wrong data returned. " . print_r($records, true)); } } print "[OK] updates work fine.\n"; /** * ===== FETCH LIST ===== */ print "running fetchList test...\n"; $adb->deleteRecords('users', ['1' => '1']); $adb->insert('users', ['name' => 'Archangel', 'surname' => 'Design', 'date' => '791']);
<?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'));