How to Connect to a Database with PHP Data Objects (PDO)

By Josh Sherman
1 min read
development
php
database

PHP Data Objects (PDO) provide a consistent interface to different databases including MySQL, PostgreSQL, SQLite, SQL Server and a handful of other systems as well. Aside from database-specific SQL, the only other thing that isn’t consistent is how to connect to a database. Each database type requires a string to […]

Split a String by Letters with PHP

By Josh Sherman
1 min read
development
php

Every once in a blue moon you find yourself needing to take a string and converting it to an array of characters in the string. Maybe it’s because you want to count how often certain letters exist in the string or want to convert the letters to something else. To […]

Passing Arguments to Command-Line PHP

By Josh Sherman
1 min read
development
php
cli

In a previous post we discussed how to tell whether or not you are on the command-line from within your PHP script. Today we’re going to talk about passing command-line arguments to your script. When on the command-line two variables are available to you, $argc and $argv. They are the […]

MySQL and Redis Command Equivalents

By Josh Sherman
7 min read
development
mysql
redis

Score another one for HitTail as this particular topic was their suggestion. MySQL (PostgreSQL, SQL Server, SQLite or any other RDBMS I didn’t list) and Redis are completely different beasts in regard to syntax and especially schema design (or lack there of). The following are just some common SQL statements […]

Calculating page load time / execution time with PHP

By Josh Sherman
1 min read
development
php

So who remembers back in the day when one of the coolest things you could have on your website’s footer was the page load time? As passé as that may seem in this day in age, it’s still something that can be useful when attempting to profile a site or […]