June 10, 2009, 10:22 pm
I needed something simple to grab images from MySQL database and display them. Slowly it grew into a very handy class.
This class can be used to manipulate images stored in files or in a MySQL database. It can read images from files and store them in a MySQL database table, and vice-versa. The class can also convert images between GIF, JPEG and PNG formats, as well resize the images to create thumbnails.
Documentation:
Coming Soon…
June 9, 2009, 6:34 pm
When I needed to know some basic information on BLOBs, I had very hard time finding it. Nearly every site I could not entirely understand at first glance. A BLOB is a “binary large object”; when using phpMyAdmin, you will see an upload form to insert a BLOB. Here is the maximum file sizes you can store in different blob fields in MySQL database.
| Type |
Sizes |
| TINYBLOB |
256 Bytes |
| BLOB |
65,536 Bytes |
64 KB |
| MEDIUMBLOB |
16,777,216 Bytes |
16,384 KB |
16 MB |
| LARGEBLOB |
4,294,967,296 Bytes |
4096 MB |
4 GB |
Easy way to calculate exact sizes:
3 GB = 3 * 1024 * 1024 * 1024
4 MB = 4 * 1024 * 1024
2 KB = 2 * 1024
In many manuals for MySQL the limit is stated in characters, for BLOBs it is: 1 Character = 1 Byte
If you store a 2 MB picture in a MEDIUMBLOB and then change the field to BLOB, the picture will be cut off. Here is what you will get if you try opening teh image with gd library after fetching from database:
On the left is original uploaded or inserted image and on the right is what was actually stored from the inserted one and outputted with PHP GD library; using imagecreatefromstring() to make the image from the string fetched from the database.
January 2, 2009, 2:34 pm
At some point I needed to paginate my results of a large database for a more friendly view. Now I use PHP so this tutorial will fully explain how to paginate using php and SQL database, or just an array with all the data. That way you can use the technique with any other database you like. I will go over the basic mechanics and the add nice things on top like pagination and sorting at the same time and how to build a wicked page navigation for the listing. And also I shall show you how to make a so called server side pagination/sorting using Ajax JavaScript at the end. Continue reading ‘PHP Pagination Guide’ »