I recently needed to sort query results to match the order of IDs passed to it for use in a WHERE β¦ IN()
clause. In MySQL, this can be done using the FIELD()
function in the ORDERY BY
clause. For Doctrine, which doesn’t have the FIELD()
function and doesn’t allow functions in the ORDER BY
clause, there’s a little more work needed to make use of it.
Database posts
Simple MySQL backup script
I made a simple bash
backup script for the newer MySQL database servers at Cogneato.
I’ve just learned that, with the MySQL command line client, one can run \s
or status;
and get a nice readout of status information.
Automatically reconnect PDO when connection times out
In PHP scripts that run queries to a MySQL database over a long period of time, the connection may time out and give a “MySQL server has gone away” error.
Continue reading post "Automatically reconnect PDO when connection times out"Import SQL file in Doctrine / PDO
I recently needed to programmatically import SQL files containing database dumps into a database managed by Doctrine ORM.
Continue reading post "Import SQL file in Doctrine / PDO"Database inheritance: Postgres?
I’ve been unhappy with the inheritance provided by PHP ORM’s I’ve looked at. In looking for something better, I discovered that Postgres has built in inheritance, because it is an object-relational database.
Continue reading post "Database inheritance: Postgres?"Objective File System
This is a modification of part of a previous post.
each file is stored in two databases: the normal hierchical db and an objective db. The hierarchical db is used for speed and for compatibility with current file systems. The objective db is used for metadata and other information less critical to basic file operations.
The objective db contains much of the metadata (non file operation related stuff). Each file type is an object type in the database, inheriting from the basic file object or one of its children. Each file type will have its own attributes as well as actions related to it. The actions may consist only of OS functions related to it, may also include application calls, and could even include user/other created scripts and functions related to the file type. The actions would provide the data from the file to the system or other function that is necessary for it to operate (functions and applications would all have a defined standard interface to them).