Scriptlog Docs

Scriptlog Documentation

Code reference for the Scriptlog codebase

User Tools

Site Tools


scriptlog:lib:core:dao

This is an old revision of the document!


Dao

Layer: Core · Source: lib/core/Dao.php:20 (lines 20–373)


class Dao

Dao Class

Data Access Object

Docblock Metadata

^ Tag ^ Value ^
| ''@category'' | Core Class |
| ''@author'' | M.Noermoehammad |
| ''@license'' | MIT |
| ''@version'' | 1.0 |
| ''@since'' | Since Release 1.0 |

Inheritance

No parent, interface or trait. This is a root type.

Constants (0)

None.

Properties (0)

None declared.

Methods (18)

^ 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 |

__construct()

public function __construct()

lines 54–67 (14)

Takes no parameters.

table()

protected function table($table)

lines 75–78 (4)

Get prefixed table name

^ Parameter ^ Type ^ Default ^ Description ^
| ''$table'' | ''(untyped)'' | //required// | //none// |

Returns: (none declared) — string

setSQL()

protected function setSQL($sql)

lines 86–89 (4)

setSQL

^ Parameter ^ Type ^ Default ^ Description ^
| ''$sql'' | ''(untyped)'' | //required// | //none// |

Returns: (none declared)

findAll()

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''

findRow()

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''

findColumn()

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''

checkCountValue()

public function checkCountValue(array $data = []): int

lines 170–182 (13)

CheckCountValue function

^ Parameter ^ Type ^ Default ^ Description ^
| ''$data'' | ''array'' | ''[]'' | //none// |

Returns: int — int

Throws: ''DbException''

create()

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)

modify()

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)

deleteRecord()

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

replaceRecord()

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)

callTransaction()

protected function callTransaction()

lines 243–246 (4)

callTransaction

begin transaction for multiple queries as a unified block

Takes no parameters.

Returns: (none declared)

callCommit()

protected function callCommit()

lines 253–256 (4)

callCommit

commit the transaction if no problems have been encountered

Takes no parameters.

Returns: (none declared)

callRollBack()

protected function callRollBack()

lines 263–266 (4)

callRollBack

to roll back the tables to their original state.

Takes no parameters.

Returns: (none declared)

runInTransaction()

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

closeConnection()

protected function closeConnection()

lines 300–303 (4)

closeConnection

Takes no parameters.

Returns: (none declared)

lastId()

protected function lastId()

lines 311–314 (4)

lastId

Takes no parameters.

Returns: (none declared) — integer

filteringId()

protected function filteringId(Sanitize $sanitize, $str, $type)

lines 325–372 (48)

Filter and sanitize input values

^ Parameter ^ Type ^ Default ^ Description ^
| ''$sanitize'' | [[scriptlog:lib:core:sanitize&#124;''Sanitize'']] | //required// | Sanitizer instance |
| ''$str'' | ''(untyped)'' | //required// | Input value to filter |
| ''$type'' | ''(untyped)'' | //required// | Sanitization type ('sql' or 'xss') |

Returns: (none declared) — int&#124;string Sanitized value as integer (sql) or string (xss)

Throws: \InvalidArgumentException


This page is generated from source by 'tools/gendoc'. Edits will be overwritten.

scriptlog/lib/core/dao.1790413761.txt.gz · Last modified: by admin