last_insert_id()

I would like to retrieve the id of a row I just inserted. In Oracle this problem is handled with the use of sequences, SQL> SELECT uid_seq.NEXTVAL INTO user_id FROM DUAL; SQL> INSERT INTO users (id, username) VALUES (user_id, ‘joebob’); 1 row created. SQL> — do something else with user_id Basically, a sequence can provide […]

php DB adapter, with magic

I would like to encapsulate the handling of database connections, and maintain a loose coupling between database connections and application and data-access code. I’ll not focus on connection pooling since that can be handled at the driver level independent of the application and adapter code. I would like to leverage the PDO interface as well […]

mysql \c

The mysql command line interface provides several very useful shortcuts. For example, the ‘tee’ command will append everything to a specified outfile: mysql> \T logfile.txt Logging to file ‘logfile.txt’ The ‘clear’ command saves from accidentally hitting Ctrl-C and disconnecting from the database: mysql> select * from typo \c mysql> The ‘clear’ command is especially useful […]