Category Archives: mysql

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'); … Continue reading

Posted in data arch., mysql, php

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 … Continue reading

Posted in mysql, php

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 … Continue reading

Posted in mysql