@@ -45,18 +45,18 @@ All parts of the project (whether Completed, In Progress or Todo) are subject to
45
45
46
46
## Initiate connection
47
47
48
-
48
+ ``` php
49
49
DB::factory(array(
50
- 'driver' => 'pdo',
51
- 'connection_string' => 'mysql:dbname=test;host=127.0.0.1',
52
- 'username' => 'root',
53
- 'password' => '',
50
+ 'driver' => 'pdo',
51
+ 'connection_string' => 'mysql:dbname=test;host=127.0.0.1',
52
+ 'username' => 'root',
53
+ 'password' => '',
54
54
));
55
-
55
+ ```
56
56
57
57
## Standard select and consequent update & delete queries
58
58
59
-
59
+ ``` php
60
60
// Execute query to get first row from table
61
61
$result = DB::factory()->for_table('test')->find_one();
62
62
@@ -70,11 +70,11 @@ All parts of the project (whether Completed, In Progress or Todo) are subject to
70
70
71
71
// Delete the row
72
72
$result->delete();
73
-
73
+ ```
74
74
75
75
## Select query with ACL
76
76
77
-
77
+ ``` php
78
78
// Define the rules, note that if the select action is not set on the table but IS set on the field then select queries will not work,
79
79
// both the table and the fields being used need to have the permission set
80
80
$rules = array(
@@ -92,11 +92,11 @@ All parts of the project (whether Completed, In Progress or Todo) are subject to
92
92
93
93
// So this will fail
94
94
$result = DB::factory()->acl()->for_table('test')->find_one();
95
-
95
+ ```
96
96
97
97
## Insert row
98
98
99
-
99
+ ``` php
100
100
// Execute query to get first row from table
101
101
$entry = DB::factory()->for_table('test');
102
102
@@ -107,11 +107,11 @@ All parts of the project (whether Completed, In Progress or Todo) are subject to
107
107
$entry->save();
108
108
109
109
$entry->delete();
110
-
110
+ ```
111
111
112
112
## Select and consequent update & delete queries on multiple entries
113
113
114
-
114
+ ``` php
115
115
// Execute query to get first row from table
116
116
$result = DB::factory()->for_table('test')->where_like('name', 'a%')->find_many();
117
117
@@ -127,15 +127,16 @@ All parts of the project (whether Completed, In Progress or Todo) are subject to
127
127
128
128
// Delete rows
129
129
$result->delete();
130
-
130
+ ```
131
131
132
132
## Model usage
133
133
134
-
134
+ ``` php
135
135
class Model_Test extends Model {
136
136
protected $table_name = 'test'; // optional, table name can be detected from class name
137
137
protected $db_id = 'default'; // redundant, 'default' is already assumed
138
138
}
139
139
140
140
$Test = new Model_Test;
141
141
$result = $Test->find_one();
142
+ ```
0 commit comments