Forked from Beteha/models/Model.php to standalone public library TPsoft/DBmodel,
added creator for build MODEL class, added basic tests
This commit is contained in:
38
test/test3.php
Normal file
38
test/test3.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__.'/../src/DBmodel.php';
|
||||
require_once __DIR__.'/../models/test.php';
|
||||
|
||||
$db = new \TPsoft\DBmodel\DBmodel('mysql:host=127.0.0.1;dbname=test;charset=utf8mb4', 'test', 'test');
|
||||
|
||||
$test = new Test();
|
||||
|
||||
// exists ID 11
|
||||
$result = $test->exist(11);
|
||||
print_r($result);
|
||||
|
||||
// insert new record
|
||||
$result = $test->test(null, array('name' => 'new record'));
|
||||
print_r($result);
|
||||
|
||||
// update record ID 11
|
||||
$result = $test->test(11, array('name' => 'updated record'));
|
||||
print_r($result);
|
||||
|
||||
// get record ID 11
|
||||
$result = $test->test(11);
|
||||
print_r($result);
|
||||
|
||||
// delete record ID 11
|
||||
$result = $test->test(11, null);
|
||||
print_r($result);
|
||||
|
||||
// get all records
|
||||
$result = $test->getList();
|
||||
print_r($result);
|
||||
|
||||
// get combined list of ID and name
|
||||
$result = $test->testCombo('id', 'name');
|
||||
print_r($result);
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user