Skip to content

Commit 5e3cd6d

Browse files
committed
Pre 7.x release updates
1 parent 1518a2f commit 5e3cd6d

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

docs/db-connector-class.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,24 @@ If you have an instance of **\LeanOrm\DBConnector** already, just call the **get
182182

183183
## Executing Queries
184184

185+
The methods below are convenience methods for executing SQL SELECT queries and getting the result back in the expected data type:
186+
187+
```php
188+
/////////////////////////////////////////////////////////////
189+
// Use this to fetch one row from a database table
190+
// - If the row exists, it is returned as an associative array
191+
// - If it doesn't exist, false is returned
185192
public function dbFetchOne(
186193
string $select_query,
187194
array $parameters = [],
188195
?object $calling_object=null
189196
): mixed
190197

198+
/////////////////////////////////////////////////////////////
199+
// Use this to fetch one or more rows from a database table
200+
// - If the query matches one or more rows, an array of
201+
// associative arrays is returned
202+
// - An empty array is returned if no row(s) are matched
191203
public function dbFetchAll(
192204
string $select_query,
193205
array $parameters = [],
@@ -211,7 +223,7 @@ If you have an instance of **\LeanOrm\DBConnector** already, just call the **get
211223
array $parameters = [],
212224
?object $calling_object=null
213225
): mixed
214-
226+
```
215227

216228
For queries that the **dbFetch\*** methods above can't handle, you can use the **runQuery** method. For example, delete, insert, complex select queries, update and other types of queries.
217229

src/LeanOrm/DBConnector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,7 @@ public function dbFetchOne(
728728

729729
$result = $this->execute($select_query, $parameters, $this->connection_name, $calling_object);
730730

731-
return ($result->pdo_statement instanceof \PDOStatement) ? $result->pdo_statement->fetch(\PDO::FETCH_ASSOC) : null;
731+
return ($result->pdo_statement instanceof \PDOStatement) ? $result->pdo_statement->fetch(\PDO::FETCH_ASSOC) : false;
732732
}
733733

734734
/**

0 commit comments

Comments
 (0)