Category Archives: php

php DB adapter, decorator

Previously, I created a php database adapter that calls mysql stored procedures as if they were local php functions. Now I want to refactor each of the features of the DB adapter into a decorator design pattern. The core database … Continue reading

Posted in php, software arch.

php DB adapter, revisited

I would like to call mysql stored procedures as if they were local php functions. For example, let's use the following mysql stored procedure, DELIMITER // CREATE PROCEDURE `usersByPage`(page_num INT, per_page INT) BEGIN SET @lim_start = (page_num - 1) * … Continue reading

Posted in mysql, php, software arch.

php echo and print

Is echo really, even negligibly, faster than print in php? Conventional wisdom of the Internet says "yes", because print performs one extra op (it returns a value). I've seen performance charts with 20% or more difference in performance. I tested … Continue reading

Posted in php

get_magic_quotes_gpc(), or not

I would like to sanitize user-supplied HTTP request variables before sending them to a database. There is a deprecated PHP setting called magic_quotes_gpc that automatically escapes GET, POST, and COOKIE (GPC) operators. Please understand that magic_quotes_gpc is highly discouraged. <?php … Continue reading

Posted in php


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

php Namespaces and Class loading

I want to autoload php classes and functions. Ideally, I want a lazy loader (include class files only when they are needed, never including more files than necessary). I'd also like namespace protection (if running PHP 5.3 or later). And … Continue reading

Posted in php