Using Transactions with PHP Data Objects (PDO)

By Josh Sherman
1 min read
development
php
database

With PHP Data Objects, transactions are pretty simple. To be able to use a transaction, you simply wrap your queries with a call to beginTransaction() and either use commit() or rollBack() at the end. Rolling back is at your discretion but the easiest implementation would be to wrap the queries […]

How to Use Prepared Statements in PHP

By Josh Sherman
3 min read
development
php
database
security

Now that we know how to create a connection to our database using PHP Data Objects, let’s talk a bit about prepared statements. Now I’d like to think that we’ve all made this mistake before, taken user input and used it in an SQL query something like this: $db->execute('SELECT * […]

Yet Another Linode vs. DigitalOcean Post

By Josh Sherman
3 min read
reviews
hosting
linode
digitalocean
nodebalancer

This has been turning into an every 3 month thing since I originally blogged about Linode vs. DigitalOcean back in late February and then again about Linode NextGen vs. DigitalOcean in May. Not to mention when I moved out of the cloud in June when I switched to bare metal […]

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 […]