Pro PHP- Patterns, Frameworks, Testing and More

(vip2019) #1

(^222) CHAPTER 15 ■ INTRODUCTION TO THE ZEND FRAMEWORK
At this point, you should be able to connect to your database:



psql -U demouser -W demodb
Password for user demouser:
Welcome to psql 8.X.X, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
demodb=>
Next, create a table. The first table you might create is one to store information about your
customers:
demodb=> create table customers(customer_id serial, name varchar);
NOTICE: CREATE TABLE will create implicit sequence
"customers_customer_id_seq" for serial column "customers.customer_id"
CREATE TABLE
Then create a record in the table:
demodb=> INSERT INTO customers (name) VALUES ('Kevin');
Finally, quit using the \q command:
demodb=> \q
Database in hand, you can now go about creating a model for your customers table, but
first you must prepare the Zend Framework to use this database.
Configuring the Framework to Use the Database
To configure the Zend Framework for use with your database, edit the bootstrap index.php file:
pico –w document_root/index.php
Add the code shown in Listing 15-5 before the line containing
Zend_Controller_Front::run.
McArthur_819-9C15.fm Page 222 Thursday, February 28, 2008 7:44 AM


Free download pdf