Repository navigation
PDOdb 3.1.0
3.1 fixes results that were wrong in 3.0.0 and earlier, so some code that depended on the old results changes. It needs the same PHP as 3.0 (8.4 or newer). Nothing is required of a custom dialect: every new dialect interface is optional.
Read Upgrading from 3.0 to 3.1 before updating.
Check these first: results can change without an error
insert()andreplace()return the key of the row the statement wrote, ornullwhen there is none to report (a skippedINSERT IGNORE, a composite key, a table without a key). 2.10 to 3.0.0 returned1there, which looked like a real id and let code attach child rows to the wrong parent. The type isint|string|null.insertFrom()andreplaceMulti()return the number of affected rows.- JSON-path comparison with a number or a boolean (
whereJsonPath(),Db::jsonPath()) is typed on all six databases. Before, the value was compared as text:age > 27selected the row with5,ok = truematched the number1andok = falsematched nothing. - Query parameters are bound with their own type instead of all as text.
where('active', false)failed on PostgreSQL and MariaDB, andfalsewas stored asNULLon Oracle. limit()andoffset()throwInvalidArgumentExceptionfor a negative number.- SQLite
REGEXP,regexp_replace()andregexp_extract()throw aQueryExceptionfor an invalid pattern. They used to warn and act as "no match", soNOT REGEXPselected every row and anUPDATEwithregexp_replace()wrote an empty string. A/in a pattern is a literal now.
Fixed
jsonSet()andjsonReplace()wrote every value as a JSON string on MariaDB, SQL Server and Oracle (999as"999",trueas"true",nullas"null"; SQL Server also added quotes to text, and Oracle'sjsonReplace()added a key named like the path instead of replacing the value). The JSON type of the value is written now.- SQL Server created
DECIMAL(10)fordecimal(10, 2), so every value was rounded to a whole number. - Insert keys stay correct after MySQL/MariaDB table changes and TEMP shadowing, without extra queries per insert.
- Oracle returns an id beyond
PHP_INT_MAXexactly; shard routing is exact for such keys. - The compiled-query cache ignored
limit()andoffset(), so a second query that differed only in them returned the rows of the first. - Cursor pagination and
batch()/each()with a key qualified by a table alias;paginate(),getValue(),getColumn()andindex()afterasObject(); a write that joins another table now drops the cached reads of the joined tables. - On PHP 8.4 a SQLite connection the library creates is a
Pdo\Sqliteobject, as on 8.5.
Every change is in the CHANGELOG.
Added
- A step-by-step guide to reliable events between services (outbox, worker, inbox), an end-to-end example that runs on every database, and a signed webhook publisher with a matching receiver.
- Optional dialect interfaces:
DialectInsertReturningInterface,DialectParameterTypesInterface,DialectMetadataMemoInterface,DialectJsonTypedComparisonInterface.
Data written by older versions
Nothing is rewritten for you. Documents written by jsonSet() on MariaDB, SQL Server and Oracle before the upgrade keep their JSON strings, and SQL Server decimal(p, s) columns created earlier keep scale 0. UPGRADE.md has a query to find each of them.
Known limits
They come from the databases, except the PostgreSQL one (details):
jsonSet()on a path whose parent object is missing writes nothing on SQL Server and Oracle (the other databases create it).jsonReplace()on a missing key creates it on SQL Server.- A string that is JSON text (
true,null,{...}) is written as that JSON, not as a string, on PostgreSQL. - A JSON string that holds a number (
"30") or a boolean ("true") matches a numeric or boolean condition on SQL Server and Oracle. - A number beyond
1e35or closer to zero than1e-30(SQL Server: beyond1e20) matches no numeric JSON condition instead of being rounded.