Database Animals

Ralph van den Berg's picture

It wasn't long ago that I've discovered that I'm not just stuck with mysql for effectively operating databases from PHP. For very small websites that need tiny databases, it's maybe easier to stick with sqlite, which uses PHP 5's built in database engine. It's fast, but limited.

For those who're still using big databases, and have a mysql server running the database, I recommend you to switch to mysqli. The 'i' on the end stands for 'improved'. Lots of the queries are exactly the same, but improved sounds good to me. To make the switch, you don't even need to rebuild your database.

Second note for PHP 5 users, orient your objects! Especially your DB interactions. It's quite easy, your database call is an object. You'll get queries like $db->query("SELECT fields FROM table");

While iterating through your results...

while($row = $result->fetch_object()) {
echo $row->field1.' '.$row->field2;
}

It really cleans up your code. What are your opinions on the database animals?