SQLITE and Laravel Query Builder and Eloquent

CREATE TABLE token (
id INTEGER PRIMARY KEY NOT NULL ,
baz varchar(255) NOT NULL,
user_id INTEGER DEFAULT NULL,
status varchar(255) NOT NULL,
created_at timestamp NOT NULL DEFAULT ‘0000-00-00 00:00:00’ ,
updated_at timestamp NOT NULL DEFAULT ‘0000-00-00 00:00:00’

) ;
+ Add index foo

Eloquent:
$token = new Token;
$token->foo = ‘ghgfhfghfghfg’;
$token->status = ‘sfdsfsdsd’;
$token->save();

echo $token->foo; /// !

QueryBuilder:

DB::table(‘token’)->insert(
array(‘foo’ => ‘dsadasdasdasdaf’, ‘status’ => ‘dsfdsfsdfasfdsafasd’)
);

SQLITE insert

How do I create an AUTOINCREMENT field? : A column declared INTEGER PRIMARY KEY will autoincrement.

http://www.sqlite.org/faq.html#q1

In SQLite, table rows normally have a 64-bit signed integer ROWID which is unique among all rows in the same table.

If a table contains a column of type INTEGER PRIMARY KEY, then that column becomes an alias for the ROWID.

http://www.sqlite.org/autoinc.html

Inserting, updating, and deleting data in SQLite : http://zetcode.com/db/sqlite/datamanipulation/

sqlite info – Migration from MySQL

Autoincrement is not prefered.

Autoincrement In SQLite : https://www.sqlite.org/autoinc.html

The AUTOINCREMENT keyword imposes extra CPU, memory, disk space, and disk I/O overhead and should be avoided if not strictly needed. It is usually not needed.

update: this bad definition
CREATE TABLE `baz` (
`id` int(11) NOT NULL ,
`bazoo` varchar(255) NOT NULL,
`status` varchar(255) NOT NULL,
`created_at` timestamp NOT NULL DEFAULT ‘0000-00-00 00:00:00’ ,
`updated_at` timestamp NOT NULL DEFAULT ‘0000-00-00 00:00:00’,
PRIMARY KEY (`id`)
) ;

the good definition:

CREATE TABLE baz (
id INTEGER PRIMARY KEY NOT NULL ,
foo varchar NOT NULL, // OR TEXT

status varchar NOT NULL,
created_at timestamp NOT NULL DEFAULT ‘0000-00-00 00:00:00’ ,
updated_at timestamp NOT NULL DEFAULT ‘0000-00-00 00:00:00’

) ;

Create index:
CREATE INDEX bazoo ON baz (bazoo);

Show table info:
PRAGMA table_info(tokens);

Show index info:
PRAGMA index_list(tokens);

SQLite – INDEXES : http://www.tutorialspoint.com/sqlite/sqlite_indexes.htm

Laravel – Setting up the SQLite Database Driver : http://laravel-recipes.com/recipes/118/setting-up-the-sqlite-database-driver

phpliteadmin: https://www.phpliteadmin.org/