myfreespace 发表于 2013-2-7 01:43:55

cakephp学习中的点滴

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');用来设置不同的布局模式

<span style="font-family: HelveticaNeue-Light, HelveticaNeue, Helvetica, Arial, sans-serif; font-size: 13px; line-height: 13px;"><ol style="margin-top: 0px; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; padding-top: 3px; padding-right: 0px; padding-bottom: 3px; padding-left: 35px; border-top-width: 1.8em; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-style: solid; border-color: #d3d3d0; font-size: 0.75em; vertical-align: baseline; background-color: #ffffff; color: #939399; line-height: 1.8em; text-align: left;" class="code">
页: [1]
查看完整版本: cakephp学习中的点滴