Jul 8, 2010

Data Access Options

There are several options I have for interacting with MySQL. I could use PHP's native msql_ functions, its new mysqli_ functions, PHP Data Objects (PDO), or a third party ActiveReocrds or ORM library. After implementing flash session variables, email validation, and a new skin, much of yesterday was spent researching these options. I'm leaning toward the mysqli_ functions, but I haven't decided yet.

Persistent database connections are only useful when PHP is installed as an Apache module. When installed as a CGI instead, the PHP process is killed when the script is done executing, killing all DB connections along with it. My shared hosting provider runs PHP as CGI by default, although the option to run as an Apache module is provided. The Apache module option has some security drawbacks on shared hosts, because other users on the system can access my scripts and files if they're not tied down securely.

I think I'll be OK with the default setup of my shared hosting platform for now. When I outgrow that, I'll move to a (virtual or real) private server. I'll run PHP as an Apache module then because I'll be the only user on the machine, making the security questions moot.

No comments:

Post a Comment