Showing posts with label databases. Show all posts
Showing posts with label databases. Show all posts

Saturday, 3 May 2008

MySQL and "serial"

In MySQL and PostgreSQL serial can be used when setting up a column in a table. It's the same as writing bigint unsigned not null auto_increment just a lot shorter to write.

Sunday, 6 April 2008

cakePHP database config

Ok this is cool.

For CakePHP, database configurations are saved in the app/config/database.php file. But notice each config is given a variable name. Any number of configs can be added in this file so that when you're working on a controller you can set the $useDbConfig variable equal to a string of the same name as your config array. Simple.

here's more info

Thursday, 20 March 2008

SQLite

SQLite seems to be an alternative to MySQL. Sure it has many benefits, by i'm sticking to MySQL for the time being.

Apparently it's fully OOP though so you can do cooler things with exception classes, and it comes with PHP 5.

Tuesday, 18 March 2008

MySQL basics

The USE database command sets the default database for your stuff. All operations from that point on are applied to that database. When declaring numeric types, a number in brackets called a width specifier which tells MySQL to pad the field when retrieving it. With floats and decimals a precision parameter can also be specified such as FLOAT(7,4). Marking a field with the ZEROFILL attribute will force MySQL to pad the value with zeros. UNSIGNED forces only positive numbers.

The alter can be used in a number of different ways to change name of fields within a table. If you try to convert field types using CHANGE, MySQL may result in errors. Try using IGNORE to get round them.

Use mysqldump to backup and restore databases or tables. Delete stuff from databases and tables using DROP.