Prev | Current Page 642 | Next

W. Jason Gilmore

"Beginning PHP and MySQL: From Novice to Professional"


1. Open a new SQLite database, as follows. Because this database presumably
doesn??™t already exist, the mere act of opening a nonexistent database will first
result in its creation:
%>sqlite corporate.db
2. Create a table:
sqlite>create table employees (
...>empid integer primary key,
...>name varchar(25),
...>title varchar(25));
570 CHAPTER 22 ?–  SQLITE
3. Check the table structure for accuracy:
sqlite>.schema employees
Note that a period (.) prefaces the schema command. This syntax requirement
holds true for all commands found under the help menu.
4. Insert a few data rows:
sqlite> insert into employees values(NULL,"Jason Gilmore","Chief Slacker");
sqlite> insert into employees values(NULL,"Sam Spade","Technologist");
sqlite> insert into employees values(NULL,"Ray Fox","Comedian");
5. Query the table, just to ensure that all is correct:
sqlite>select * from employees;
You should see the following:
1|Jason Gilmore|Chief Slacker
2|Sam Spade|Technologist
3|Ray Fox|Comedian
6. Quit the interface with the following command:
sqlite>.quit
?– Note PHP 5.X is bundled with SQLite version 2; however, SQLite version 3 has been out for quite
some time. Therefore, if you wish to use the SQLite command-line interface to create a database and
then move it to a location for interaction with a PHP script, be sure to have downloaded SQLite version
2 because the database file formats between these two versions are incompatible.


Pages:
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654