Prev | Current Page 160 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

This is done in function called _setupDatabase() which is called by setUp() as shown in Listing 5.11.
Listing 5.11: Initializing the database in setUp()
public function setUp() #1
{
// reset database to known state
$this->_setupDatabase();
}
protected function _setupDatabase()
{
$this->db->query('DROP TABLE IF EXISTS users;'); #2
Licensed to Menshu You
Please post comments or corrections to the Author Online forum at
http://www.manning-sandbox.com/forum.jspa?forumID=329
$this->db->query(<<CREATE TABLE users ( |
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, |
date_created DATETIME, |
date_updated DATETIME, |
username VARCHAR(100) NOT NULL, |
password VARCHAR(40) NOT NULL, |
first_name VARCHAR(100), |
last_name VARCHAR(100), |
email VARCHAR(150) NOT NULL, |
town VARCHAR(100), |
country VARCHAR(100), |
date_of_birth datetime, |
sex char(1), |
postcode VARCHAR(30) |
) |
EOT |
);
// insert row #1 #4
$row = array (
'first_name' => 'Rob',
'last_name' => 'Allen',
'username' => 'rob',
'password' => 'rob',
'email' => 'rob@akrabat.com',
'town' => 'London',
'country' => 'UK',
'date_of_birth' => '1970-01-04',
'sex' => 'M',
'date_created' => '2007-02-14 00:00:00',
);
$this->db->insert('users', $row);
// insert row #2
$row = array (
'first_name' => 'Julie',
'last_name' => 'Smith',
'username' => 'julie',
'password' => 'julie',
'email' => 'julie@example.


Pages:
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
lampy ogrodowe określić zakłady bukmacherskie Wczasy nad morzem Gabi meble Warszawa