Skip to content

Commit b668d00

Browse files
committed
Merge branch 'master' into v4
2 parents 7812890 + cca7f4e commit b668d00

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

README.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ prepareOff(); // When off shortcut SQL Methods calls will use vendors escape rou
123123
query_prepared(string $query_string, array $param_array);
124124
```
125125

126-
#### An Example for using prepare statements indirectly, with above shortcut SQL methods
126+
#### Example for using prepare statements indirectly, with above shortcut SQL methods
127127

128128
```php
129129
// To get all shortcut SQL methods calls to use prepare statements
@@ -134,17 +134,48 @@ $values['name'] = $user;
134134
$values['email'] = $address;
135135
$values['phone'] = $number;
136136
$db->insert('abc_db', $values);
137+
$db->insert('abc_db', ['name' => 'john john', 'email' => 'john@email', 'phone' => 123456]);
137138

139+
// returns result set given the table name, column fields, and ...conditionals
138140
$result = $db->selecting('abc_db', 'phone',
141+
// ...conditionals are comparison operators($column, $value, _COMBINE_EXPRESSION_CONSTANTS)
142+
// these operators are functions returning arrays:
143+
// eq(), neq(), ne(), lt(), lte(),
144+
// gt(), gte(), isNull(), isNotNull(),
145+
// like(), notLike(), in(), notIn(), between(), notBetween(),
146+
// _COMBINE_EXPRESSION_CONSTANTS:
147+
// _AND, _OR, _NOT, _andNOT
139148
eq('email', $email, _AND), neq('id', 1)
140149
);
141150

142151
foreach ($result as $row) {
143152
echo $row->phone);
144153
}
154+
155+
$result = $db->selecting('abc_db', 'name, email',
156+
// Conditionals can also be called, stacked with other functions like:
157+
// innerJoin(), leftJoin(), rightJoin(), fullJoin()
158+
// as (leftTable, rightTable, leftColumn, rightColumn, equal condition),
159+
// where( eq( columns, values, _AND ), like( columns, _d ) ),
160+
// groupBy( columns ),
161+
// having( between( columns, values1, values2 ) ),
162+
// orderBy( columns, desc ),
163+
// limit( numberOfRecords, offset ),
164+
// union(table, columnFields, conditions),
165+
// unionAll(table, columnFields, conditions)
166+
$db->where( eq('phone', $number, _OR), neq('id', 5) ),
167+
// another way: where( array(key, operator, value, combine, combineShifted) );
168+
// or as strings double spaced: where( "key operator value combine combineShifted" );
169+
$db->orderBy('name'),
170+
$db->limit(1)
171+
);
172+
173+
foreach ($result as $row) {
174+
echo $row->name.' '.$row->email);
175+
}
145176
```
146177

147-
#### An Example for using prepare statements directly, no shortcut SQL methods used
178+
#### Example for using prepare statements directly, no shortcut SQL methods used
148179

149180
```php
150181
$db->query_prepared('INSERT INTO abc_db( name, email, phone) VALUES( ?, ?, ? )', [$user, $address, $number]);

0 commit comments

Comments
 (0)