1. Before use database we must configurate database information first.
We can use config.ini file containing the DB info. And use function Zend_Config_Ini() to get the file content.

config.ini file:
Code

usually we will use Initializer.php file to do all initialization work.

Here is two functions about configurate server info and intialize DB.

Code

 

Using Profile:
--getTotalNumQueries() returns the total number of queries that have been profiled.
--getTotalElapsedSecs() returns the total number of seconds elapsed for all profiled queries.
--getQueryProfiles() returns an array of all query profiles.
--getLastQueryProfile() returns the last (most recent) query profile, regardless of whether or not the query has finished (if it hasn't, the end time will be null)
--clear() clears any past query profiles from the stack.
--getQuery() returns the SQL text of the query. The SQL text of a prepared statement with parameters is the text at the time the query was prepared, so it contains parameter placeholders, not the values used when the statement is executed.
--getQueryParams() returns an array of parameter values used when executing a prepared query. This includes both bound parameters and arguments to the statement's execute() method. The keys of the array are the positional (1-based) or named (string) parameter indices.

--getElapsedSecs() returns the number of seconds the query ran.

Code

 

2. Zend_Db_Table

usually we will create a table class extends Zend_Db_Table_Abstract can do all execution inside the class
Here we have four DB tabls, they are associated, so when we create these table class, we must define their relationships
Code

Code
2.1 Fetching a Dependent Rowset:
Code

2.2 Fetching a Parent Row


Code

 2.3 Fetching a Rowset via a Many-to-many Relationship

Code