Skip to content

Commit

Permalink
add User model
Browse files Browse the repository at this point in the history
tweak index controller
  • Loading branch information
jianqingebay committed Dec 6, 2011
1 parent 3fbb2d1 commit 1c0d1ea
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
18 changes: 18 additions & 0 deletions application/controllers/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@ public function init()
public function indexAction()
{
// action body
$dbconf = new Zend_Config_Ini(APPLICATION_PATH.'/configs/application.ini','development');
$db = Zend_Db::factory($dbconf->database);

Zend_Db_Table_Abstract::setDefaultAdapter($db);
Zend_Registry::set('db',$db);

require_once APPLICATION_PATH . '/models/User.php';

$user = new Users(); // Users Table Object.
$rowset = $user->fetchAll()->toArray();
$list_of_users = array();

foreach($rowset as $row) {
$list_of_users[] = $row->id;
}
//$this->view->userlist
$this->view->id = 2;

}

public function ajaxAction()
Expand Down
16 changes: 16 additions & 0 deletions application/models/User.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/**
* Short description for class
*
* Long description for class (if any)...
*
* @copyright Copyright (c) 2011 eBay Inc. All Rights Reserved
* @license Confidential - intended only for the use of eBay employees
* @version 1.0 (Nov 30, 2011)
* @author jianqsun
*/
class Users extends Zend_Db_Table_Abstract {
protected $_name = 'users';

}
1 change: 1 addition & 0 deletions application/views/scripts/index/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ body
<ul>
<li>tab1</li>
<li>tab2</li>
<?=$this->id;?>
</ul>
</div>
</div>
13 changes: 13 additions & 0 deletions public/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,22 @@
get_include_path(),
)));

// Include models
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/models'),
get_include_path(),
)));

/** Zend_Application */
require_once 'Zend/Application.php';
/*
$dbconf = new Zend_Config_Ini(APPLICATION_PATH.'/configs/application.ini','development');
$db = Zend_Db::factory($dbconf->database);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
Zend_Registry::set('db',$db);
*/
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
Expand Down

0 comments on commit 1c0d1ea

Please sign in to comment.