Complete reference for PDOdb public API.
new PdoDb(?string $driver = null, array $config = [], array $pdoOptions = [], ?LoggerInterface $logger = null)find()- Get QueryBuilder instancerawQuery(string|RawValue, array)- Execute raw SQL, return arrayrawQueryOne(string|RawValue, array)- Execute raw SQL, return single rowrawQueryValue(string|RawValue, array)- Execute raw SQL, return single value
startTransaction()- Begin transactioncommit()- Commit transactionrollback()- Roll back transactioninTransaction()- Check if transaction is activetransaction(callable)- Execute callback in transaction
addConnection(string, array, array, ?LoggerInterface)- Add named connectionhasConnection(string)- Check if connection existsconnection(string)- Switch to named connectiondisconnect(?string)- Disconnect from connection(s)ping()- Test connection
setTimeout(int)- Set query timeoutgetTimeout()- Get current timeout
describe(string)- Get table structureexplain(string, array)- Analyze query executionexplainAnalyze(string, array)- Detailed query analysis
lock(string|array)- Lock tablesunlock()- Unlock tablessetLockMethod(string)- Set lock method (READ/WRITE)
$lastQuery- Last executed query$lastError- Last error message$lastErrNo- Last error code$executeState- Execution status$connection- Current connection interface
from(string)- Set tabletable(string)- Alias for from()select(array|string|RawValue)- Set columnswhere(...)- Add WHERE conditionandWhere(...)- Add AND WHEREorWhere(...)- Add OR WHEREhaving(...)- Add HAVING conditionorHaving(...)- Add OR HAVING
get()- Execute and get all rowsgetOne()- Execute and get first rowgetColumn()- Execute and get column valuesgetValue()- Execute and get single valueexists()- Check if records existnotExists()- Check if no records existtableExists()- Check if table exists
insert(array)- Insert single rowinsertMulti(array)- Insert multiple rowsupdate(array)- Update rowsdelete()- Delete rowsreplace(array)- Replace rowtruncate()- Truncate table
limit(int)- Limit resultsoffset(int)- Set offsetorderBy(string|RawValue, string)- Add ORDER BYgroupBy(string|array|RawValue)- Add GROUP BY
join(string, string|RawValue, string)- Add JOINleftJoin(string, string|RawValue)- LEFT JOINrightJoin(string, string|RawValue)- RIGHT JOINinnerJoin(string, string|RawValue)- INNER JOIN
batch(int)- Process in batches (returns Generator)each(int)- Process one at a time (returns Generator)stream()- Stream results (returns Generator)
toSQL()- Get SQL and parametersexplain()- Execution planexplainAnalyze()- Detailed analysisdescribe()- Table structure
option(string|array)- Add query optionsasObject()- Fetch as objectsprefix(string)- Set table prefixonDuplicate(array)- UPSERT clause
Db::raw(string, array)- Raw SQL expressionDb::escape(string)- Escape stringDb::config(...)- Database config
Db::null()- NULL valueDb::isNull(string)- IS NULLDb::isNotNull(string)- IS NOT NULLDb::ifNull(...)- Handle NULL
Db::inc(int)- IncrementDb::dec(int)- DecrementDb::abs(...)- Absolute valueDb::round(...)- Round numberDb::mod(...)- Modulo
Db::concat(...)- ConcatenateDb::upper(...)- UppercaseDb::lower(...)- LowercaseDb::trim(...)- Trim whitespace
Db::now(string)- Current timestampDb::ts(string)- Unix timestampDb::curDate()- Current dateDb::curTime()- Current time
Db::jsonObject(...)- JSON objectDb::jsonArray(...)- JSON arrayDb::jsonGet(...)- Get JSON valueDb::jsonContains(...)- Check if contains
Db::like(...)- LIKE patternDb::between(...)- Value rangeDb::in(...)- IN arrayDb::isNull(...)- NULL check
- Query Builder Methods - Detailed QueryBuilder reference
- Helper Functions Reference - Complete helper functions