• About Me




    Lily@Melbourne, Australia

    Login

  • Follow 静水深流 || Still waters run deep on WordPress.com
  • Archives

CakePHP Dashboard

首先我要隆重推荐这一篇文章>>,它是我写Dashboard的start-point,在这之前,几乎毫无概念。
Model:

App::uses('AppModel', 'Model');
class Dashboard extends AppModel {
public $useTable = false; //不和数据库关联
}

Controller:

public $uses = array();

public function index () {
$user_id = $this->Auth->user('id'); 
$this->set('viewCustomer', ClassRegistry::init('Customer')->
find('first', array('conditions' => array('User.id' => $user_id))));//用获取的用户名搜索Customer数据库
$this->set('topEmployees', ClassRegistry::init('Employee')->getTopPerformers()); //model下有这个method
}

View:

<td><?php echo $viewCustomer['Customer']['id']; ?>&nbsp;</td>//显示获得的数据

当然还要加一点CSS之类的,当然这不是这篇文章的主题了

结果:

DashBoard

DashBoard

Advertisements

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s

%d 博主赞过: