#pdo Clear
Tags #php #kotlin #bash #go #sql #rust #typescript #html #java #python #files #utils #strings #http #concurrency #async #json #arrays #security #types #crypto #database #dates #format
PHP Auto-Reconnect on "MySQL has gone away"
Long-running daemons sometimes lose their MySQL connection mid-run. Wrap your DB calls to retry once after a transient connection-lost error.
PHP PDO Transaction Wrapper
Run a closure inside a transaction. Commits on success, rolls back on any exception, then re-throws so the caller can react. Avoids the bug-prone copy-paste of begin/commit/rollBack.
PHP Paginated Query Helper
Run a SELECT with LIMIT/OFFSET and also return the total row count, so you can render "Page 3 of 47" UIs. Single function, two round trips.
PHP Bulk INSERT in a Single Statement
Insert a list of rows in one round trip by building a multi-VALUES statement with placeholders. Orders-of-magnitude faster than looping single INSERTs.
PHP Build WHERE IN with Placeholders
Safely interpolate a variable-length list into a "WHERE col IN (...)" clause. Returns the SQL fragment plus the bound parameters — never concatenate user values into SQL.
PHP PDO Connection with Sensible Defaults
Open a PDO connection with all the options you almost always want: real prepared statements, exceptions on error, associative-array fetch mode, UTF-8 charset.