-
Notifications
You must be signed in to change notification settings - Fork 0
/
example_sqlite.php
88 lines (65 loc) · 1.51 KB
/
example_sqlite.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once 'vendor/autoload.php';
/* //use 1
use Stnc\Db\SQLiteAdapter ;
$db = new SQLiteAdapter();
*/
/* //use 2
use Stnc\Db\SQLiteAdapter as dbs;
$db = new dbs();
*/
//use 3
$db = new Stnc\Db\SQLiteAdapter("sqllite_example.db");
$tableName = 'CRM_IDENTITYLIST';
// multiple rows
echo $q = "SELECT * FROM ".$tableName;
$array_expression = $db->fetchAll ( $q );
foreach ( $array_expression as $value ) {
echo $value ['Scope'];
echo '<br>';
}
// single row
$q = "SELECT * FROM ".$tableName ." where id=1";
$array_expression = $db->fetch ( $q );
echo $value ['Scope'];
//print_r($array_expression);
/*
// query metod mysq only
$q = "ALTER TABLE users MODIFY COLUMN id int(11) NOT NULL AUTO_INCREMENT FIRST";
$db->query ( $q );
*/
// insert data
$data = array (
'ID' => 44555,
'LastNumber' => 44555,
'Scope' => "carter",
'Subsidiary' => "carter",
);
//print_r($data );
$db->insert ( $tableName, $data );
// update metod
$data = array (
'LastNumber' => 656656,
'Scope' => "carter2",
'Subsidiary' => "carter4",
);
$where = array (
'ID' => 1
);
$db-> update ( $tableName, $data, $where );
$where = array (
'ID' => 5
);
$db->delete ( $tableName, $where );
//last id
$db->lastID();
/*
///NEW MTEOD //Chaining methods where update //orm step 2
$db->where('ID', '=', 1)->update2(['LastNumber' =>656656]);
//orm step 1
$db->tableName=$tableName;
$array_expression = $db->where_test ( 'ID','=','1' );
*/