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:
]
; Database Settings
db.adapter  = PDO_MySQL    ; A Zend_Db adapter name
db
.dbname   = zend_study
db
.hostname = localhost
db
.username = pma
db
.password = 123456

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

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

}

 

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.

;

 

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
);

}
2.1 Fetching a Dependent Rowset:

2.2 Fetching a Parent Row


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

// -- $row->find<TableClass>Via<IntersectionTableClass>By<Rule1>And<Rule2> ([Zend_Db_Table_Select $select])

相关文章:

  • 2021-07-14
  • 2022-02-24
  • 2021-08-27
  • 2022-12-23
  • 2021-06-25
  • 2021-07-27
  • 2021-09-19
  • 2021-09-08
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-24
  • 2021-12-13
  • 2022-02-20
  • 2021-07-29
  • 2022-12-23
相关资源
相似解决方案