Layer: Core · Source: lib/core/Dao.php:20 (lines 20–373)
class Dao
Dao Class
Data Access Object
| Tag | Value |
|---|---|
@category | Core Class |
@author | M.Noermoehammad |
@license | MIT |
@version | 1.0 |
@since | Since Release 1.0 |
No parent, interface or trait. This is a root type.
None.
| Visibility | Type | Name | Default | Line |
|---|---|---|---|---|
protected | (untyped) | $dbc | 27 | |
protected | (untyped) | $sql | 33 | |
protected | (untyped) | $error | 39 | |
protected | (untyped) | $sanitizing | 46 | |
protected | (untyped) | $prefix | 52 |
| Visibility | Method | Summary | Line |
|---|---|---|---|
| public | __construct() | (undocumented) | 54 |
| protected | table() | Get prefixed table name | 75 |
| protected | setSQL() | setSQL | 86 |
| protected | findAll() | Find All records | 100 |
| protected | findRow() | Find Single row record | 124 |
| protected | findColumn() | Find Column | 148 |
| public | checkCountValue() | CheckCountValue function | 170 |
| protected | create() | Create records | 191 |
| protected | modify() | Modify record | 204 |
| protected | deleteRecord() | deleteRecord() | 220 |
| protected | replaceRecord() | replaceRecord() | 233 |
| protected | callTransaction() | callTransaction | 243 |
| protected | callCommit() | callCommit | 253 |
| protected | callRollBack() | callRollBack | 263 |
| public | runInTransaction() | Run a callable inside a single database transaction. | 280 |
| protected | closeConnection() | closeConnection | 300 |
| protected | lastId() | lastId | 311 |
| protected | filteringId() | Filter and sanitize input values | 325 |
public function __construct()
lines 54–67 (14)
Takes no parameters.
protected function table($table)
lines 75–78 (4)
Get prefixed table name
| Parameter | Type | Default | Description |
|---|---|---|---|
$table | (untyped) | required | none |
Returns: (none declared) — string
protected function setSQL($sql)
lines 86–89 (4)
setSQL
| Parameter | Type | Default | Description |
|---|---|---|---|
$sql | (untyped) | required | none |
Returns: (none declared)
protected function findAll(array $data = array(), $fetchMode = null)
lines 100–112 (13)
Find All records
getting array of rows
| Parameter | Type | Default | Description |
|---|---|---|---|
$data | array | array() | none |
$fetchMode | (untyped) | null | none |
Returns: (none declared) — array<array-key, mixed>
Throws: ''DbException''
protected function findRow(array $data = array(), $fetchMode = null)
lines 124–136 (13)
Find Single row record
getting one row
| Parameter | Type | Default | Description |
|---|---|---|---|
$data | array | array() | none |
$fetchMode | (untyped) | null | none |
Returns: (none declared) — mixed
Throws: ''DbException''
protected function findColumn(array $data = array(), $fetchMode = null)
lines 148–160 (13)
Find Column
return a single column from the next row of results set getting single field value
| Parameter | Type | Default | Description |
|---|---|---|---|
$data | array | array() | none |
$fetchMode | (untyped) | null | none |
Returns: (none declared) — boolean false if no more rows
Throws: ''DbException''
public function checkCountValue(array $data = []): int
lines 170–182 (13)
CheckCountValue function
| Parameter | Type | Default | Description |
|---|---|---|---|
$data | array | [] | none |
Returns: int — int
Throws: ''DbException''
protected function create($table, $params)
lines 191–194 (4)
Create records
| Parameter | Type | Default | Description |
|---|---|---|---|
$table | (untyped) | required | none |
$params | (untyped) | required | none |
Returns: (none declared)
protected function modify($table, $params, $where)
lines 204–207 (4)
Modify record
| Parameter | Type | Default | Description |
|---|---|---|---|
$table | (untyped) | required | none |
$params | (untyped) | required | none |
$where | (untyped) | required | none |
Returns: (none declared)
protected function deleteRecord($table, $where, ?int $limit = 1)
lines 220–223 (4)
deleteRecord()
Delete matching record(s). When $limit is null, all matching rows are removed; otherwise at most $limit rows are deleted.
| Parameter | Type | Default | Description |
|---|---|---|---|
$table | (untyped) | required | none |
$where | (untyped) | required | none |
$limit | ?int | 1 | Maximum rows to delete, or null to delete all |
Returns: (none declared) — int Number of rows deleted
protected function replaceRecord($table, $params, $to)
lines 233–236 (4)
replaceRecord()
| Parameter | Type | Default | Description |
|---|---|---|---|
$table | (untyped) | required | none |
$params | (untyped) | required | none |
$to | (untyped) | required | none |
Returns: (none declared)
protected function callTransaction()
lines 243–246 (4)
callTransaction
begin transaction for multiple queries as a unified block
Takes no parameters.
Returns: (none declared)
protected function callCommit()
lines 253–256 (4)
callCommit
commit the transaction if no problems have been encountered
Takes no parameters.
Returns: (none declared)
protected function callRollBack()
lines 263–266 (4)
callRollBack
to roll back the tables to their original state.
Takes no parameters.
Returns: (none declared)
public function runInTransaction(callable $work)
lines 280–294 (15)
Run a callable inside a single database transaction.
All DAO instances share the same Db connection from the Registry, so a transaction begun here atomically covers operations performed across multiple DAOs (e.g. comment anonymization + post reassignment + user deletion during GDPR erasure). Rolls back and rethrows on any Throwable.
| Parameter | Type | Default | Description |
|---|---|---|---|
$work | callable | required | The work to run inside the transaction |
Returns: (none declared) — mixed The callable's return value
Throws: \Throwable
protected function closeConnection()
lines 300–303 (4)
closeConnection
Takes no parameters.
Returns: (none declared)
protected function lastId()
lines 311–314 (4)
lastId
Takes no parameters.
Returns: (none declared) — integer
protected function filteringId(Sanitize $sanitize, $str, $type)
lines 325–372 (48)
Filter and sanitize input values
| Parameter | Type | Default | Description |
|---|---|---|---|
$sanitize | ''Sanitize'' | required | Sanitizer instance |
$str | (untyped) | required | Input value to filter |
$type | (untyped) | required | Sanitization type ('sql' or 'xss') |
Returns: (none declared) — int|string Sanitized value as integer (sql) or string (xss)
Throws: \InvalidArgumentException
This page is generated from source by 'tools/gendoc'. Edits will be overwritten.