Skip to content

Commit 7c004c7

Browse files
committed
Merge branch 'master' into v4
2 parents b668d00 + 38e3c23 commit 7c004c7

File tree

2 files changed

+43
-24
lines changed

2 files changed

+43
-24
lines changed

README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Example
6767

6868
```php
6969
// Creates an database table
70-
create('abc_db',
70+
create('profile',
7171
// and with database column name, datatype
7272
// data types are global CONSTANTS
7373
// SEQUENCE|AUTO is placeholder tag, to be replaced with the proper SQL drivers auto number sequencer word.
@@ -121,6 +121,8 @@ prepareOff(); // When off shortcut SQL Methods calls will use vendors escape rou
121121
// With the same number of arguments in an array.
122122
// It will determine arguments type, execute, and return results.
123123
query_prepared(string $query_string, array $param_array);
124+
// Will need to call to get last successful query result, will return an object array
125+
queryResult();
124126
```
125127

126128
#### Example for using prepare statements indirectly, with above shortcut SQL methods
@@ -133,11 +135,11 @@ $values = [];
133135
$values['name'] = $user;
134136
$values['email'] = $address;
135137
$values['phone'] = $number;
136-
$db->insert('abc_db', $values);
137-
$db->insert('abc_db', ['name' => 'john john', 'email' => 'john@email', 'phone' => 123456]);
138+
$db->insert('profile', $values);
139+
$db->insert('profile', ['name' => 'john john', 'email' => 'john@email', 'phone' => 123456]);
138140

139141
// returns result set given the table name, column fields, and ...conditionals
140-
$result = $db->selecting('abc_db', 'phone',
142+
$result = $db->selecting('profile', 'phone',
141143
// ...conditionals are comparison operators($column, $value, _COMBINE_EXPRESSION_CONSTANTS)
142144
// these operators are functions returning arrays:
143145
// eq(), neq(), ne(), lt(), lte(),
@@ -152,7 +154,7 @@ foreach ($result as $row) {
152154
echo $row->phone);
153155
}
154156

155-
$result = $db->selecting('abc_db', 'name, email',
157+
$result = $db->selecting('profile', 'name, email',
156158
// Conditionals can also be called, stacked with other functions like:
157159
// innerJoin(), leftJoin(), rightJoin(), fullJoin()
158160
// as (leftTable, rightTable, leftColumn, rightColumn, equal condition),
@@ -178,7 +180,14 @@ foreach ($result as $row) {
178180
#### Example for using prepare statements directly, no shortcut SQL methods used
179181

180182
```php
181-
$db->query_prepared('INSERT INTO abc_db( name, email, phone) VALUES( ?, ?, ? )', [$user, $address, $number]);
183+
$db->query_prepared('INSERT INTO profile( name, email, phone) VALUES( ?, ?, ? );', [$user, $address, $number]);
184+
185+
$db->query_prepared('SELECT name, email FROM profile WHERE phone = ? OR id != ?', [$number, 5]);
186+
$result = $db->queryResult(); // the last query that has results are stored in `last_result` protected property
187+
188+
foreach ($result as $row) {
189+
echo $row->name.' '.$row->email);
190+
}
182191
```
183192

184193
## For Authors and **[Contributors](https://github.com/ezSQL/ezsql/blob/master/CONTRIBUTORS.md)**

lib/ezsqlModel.php

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -626,12 +626,12 @@ public function timer_update_global($timer_name)
626626
}
627627

628628
/**
629-
* Function for operating query count
630-
*
631-
* @param bool $all Set to false for function to return queries only during this connection
632-
* @param bool $increase Set to true to increase query count (internal usage)
633-
* @return int Returns query count base on $all
634-
*/
629+
* Function for operating query count
630+
*
631+
* @param bool $all Set to false for function to return queries only during this connection
632+
* @param bool $increase Set to true to increase query count (internal usage)
633+
* @return int Returns query count base on $all
634+
*/
635635
public function count($all = true, $increase = false)
636636
{
637637
if ($increase) {
@@ -642,23 +642,33 @@ public function count($all = true, $increase = false)
642642
return ($all) ? $this->num_queries : $this->conn_queries;
643643
}
644644

645-
/**
646-
* Returns, whether a database connection is established, or not
647-
*
648-
* @return boolean
649-
*/
645+
/**
646+
* Returns, whether a database connection is established, or not
647+
*
648+
* @return boolean
649+
*/
650650
public function isConnected()
651651
{
652652
return $this->_connected;
653-
} // isConnected
653+
} // isConnected
654654

655-
/**
656-
* Returns the affected rows of a query
657-
*
658-
* @return int
659-
*/
655+
/**
656+
* Returns the affected rows of a query
657+
*
658+
* @return int
659+
*/
660660
public function affectedRows()
661661
{
662662
return $this->_affectedRows;
663-
} // affectedRows
663+
} // affectedRows
664+
665+
/**
666+
* Returns the last query result
667+
*
668+
* @return array
669+
*/
670+
public function queryResult()
671+
{
672+
return $this->last_result;
673+
}
664674
} // ezsqlModel

0 commit comments

Comments
 (0)