手机浏览 RSS 2.0 订阅 膘叔的简单人生 , 腾讯云RDS购买 | 超便宜的Vultr , 注册 | 登陆

Yii Framework DB 中的一些参数

首页 > PHP >

Yii的AR一直在被使用,当然,偶尔也只是看看其中的参数,都是直接把main.php中的数据注释掉就完事了
但事实上我们都忽略了一点点现实,那就是默认参数是没有什么性能提升的。

1、'schemaCachingDuration'=>3600,
这个在默认参数中是不存在的,如果你的表结构不太变动,完全可以不需要每次都show columns,show create table之类的。加上这个参数,可以将表结构缓存一小时(嗯,前提是,你配置了cache组件)

2、emulatePrepare=true ,这个是默认里面就带有的,它有什么用呢?
官方是这样说的:whether to turn on prepare emulation. Defaults to false, meaning PDO will use the native prepare support if available. For some databases (such as MySQL), this may need to be set true so that PDO can emulate the prepare support to bypass the buggy native prepare support. Note, this property is only effective for PHP 5.1.3 or above.
好吧,为了以防万一,还是打开算了

3、'enableProfiling'=>true
如果你想优化代码的话,可以尝试设置为true看看。官方在guide里说:By setting CDbConnection::enableProfiling to be true in the application configuration, every SQL statement being executed will be profiled. The results can be readily displayed using the aforementioned CProfileLogRoute, which can show us how much time is spent in executing what SQL statement. We can also call CDbConnection::getStats() to retrieve the total number SQL statements executed and their total execution time.

4、 'enableParamLogging'=>true,
这个就相对比较简单了,如果你设置为True,你在log中,就可以看到你的每次参数的参数是什么了,而不是:y01:y02这样的顺序变量。

5、tablePrefix = "xxx",这没什么好解释的。。。

6、charset="xxx" ,也没有什么好解释的,utf-8的话,中间的减号不要。。


这些都是常用的。。所以列出来




本站采用创作共享版权协议, 要求署名、非商业和保持一致. 本站欢迎任何非商业应用的转载, 但须注明出自"易栈网-膘叔", 保留原始链接, 此外还必须标注原文标题和链接.

Tags: yii

« 上一篇 | 下一篇 »

只显示10条记录相关文章

常用网站的反向代理页[2013-09-28] (浏览: 66180, 评论: 10)
Yii CDbCriteria的常用方法 (浏览: 56466, 评论: 5)
将Yiiframework与JQuery easyUI整合使用 (浏览: 38316, 评论: 2)
Yii:relations update(self::STAT) (浏览: 33870, 评论: 0)
值得收藏的yii2的doc中关于db Query的说明 (浏览: 29376, 评论: 0)
Yii Demos 随想 (浏览: 28660, 评论: 3)
在Yii框架中使用Hprose或PHPRPC (浏览: 27674, 评论: 0)
Yii ClinkPager 郁闷 (浏览: 27411, 评论: 2)
Yiiframework(Yii框架)开发笔记:续四 (浏览: 26886, 评论: 3)
Yii 一行代码,为模块绑定子域名 (浏览: 26185, 评论: 0)

1条记录访客评论

By setting CDbConnection::enableProfiling to be true in the application configuration, every SQL statement being executed will be profiled.

Post by 衣柜 on 2012, March 8, 2:49 PM 引用此文发表评论 #1


发表评论

评论内容 (必填):