string serial(void)
This method is used in "CREATE TABLE" queries. For MySQL, it returns the string "INTEGER NOT NULL AUTO_INCREMENT PRIMARY KEY". For PostgreSQL, it returns the string "SERIAL". Using this method when creating a table will cause the following:
- The data type for the column will be an integer in the range from 0 to 2147483647 (in MySQL, however, the range will be from -2147483648 to 2147483647).
- The column will automatically be incremented.
- A unique index on the column will be created.
<?php
require_once("fasdab.mysql.php");
$db = new Fasdab("localhost", "username", "password", "database");
$db->query("CREATE TABLE users (
id ".$db->serial().",
first_name varchar(255),
last_name varchar(255),
age integer
)");
?>