CrankBerry Blog Title

Posts for ‘MySQL’

2010


(2) Comments

Random row from your MySQL table with PHP, alternative to ORDER BY rand()

Categories :: MySQL, PHP

Working with MySQL and PHP is awesome. Its one of the best way to manage your data, but once in a while you may want to do some randomizing. One problem I came across recently was how to select a random row from your MySQL table with PHP. Using the ORDER BY rand() method in your query maybe a bit slow so here's what we've got.

2010


No Comments

Automated MySQL database backup with PHP and cronjob

Categories :: PHP, Tools, Web Owners

At some point of working on your website you'll want to back up you MySQL database. This is they key for all of you building dynamic sites. If one day your server goes down or something you may have the files backed up but without the database you'll have to start from scratch again. If you operate a very slow-paced site then manual back up is fine but if you want to backup your database daily then it becomes tedious. I, myself is lazy so I came up with a PHP and Cronjob solution to automatically backup MySQL database.