1 model层的操作 基类为dbo_mysql.php cake/libs/datasources/datasources/dbo/dbo_mysql.php
内部用到了dbo_source.php中的方法主要是对表进行拆分和处理,拼接sql语句
以此继承了datasource.php中主要定义了接口和类的基本方法
该类封装了对mysql数据库的基本操作和测试 检测方法,可以调用$this->query()来执行sql语句
数据库的连接
function connect() {
$config = $this->config;
$this->connected = false;
if (!$config['persistent']) {
$this->connection = mysql_connect($config['host'] . ':' . $config['port'], $config['login'], $config['password'], true);
$config['connect'] = 'mysql_connect';
} else {
$this->connection = mysql_pconnect($config['host'] . ':' . $config['port'], $config['login'], $config['password']);
}
if (mysql_select_db($config['database'], $this->connection)) {
$this->connected = true;
}
if (!empty($config['encoding'])) {
$this->setEncoding($config['encoding']);
}
$this->_useAlias = (bool)version_compare(mysql_get_server_info($this->connection), "4.1", ">=");
return $this->connected;
}
2,在controllers的方法中输出数据到views模板中
试图层有layouts布局 elements元素 helpers
可以自定义布局 只需要放在views下的 layout下就可以了 在controller中可以通过layout来选择不同的布局格
var $helpers = array('Form', 'Html', 'Javascript', 'Time');用来设置不同的布局模式