摘要: Adding id and class names to CMenuWe use the id and htmlOptions to accomplish this. Watch.//in your view$this->widget('zii.widgets.CMenu', array( 'id'=>'myMenu', 'items'=>$this->myMenu, 'htmlOptions'=>array('class'=>'span-24 last& 阅读全文
posted @ 2012-10-18 13:23 zaric 阅读(1377) 评论(0) 推荐(0) 编辑
摘要: 今天优化了多条SQL语句。都是EXPLAIN的功劳,分析SQL子句的执行顺序和执行情况,一木了然,下来看具体分析:[优化多表联合查询]explain SELECT sql_no_cache pker.*,pk.* FROM ng_game_pk AS pk ,ng_game_pker AS pker where pker.pkid = pk.id and (pker.act_uid = 1 OR pker.def_uid = 1) AND pk.type <>4 GROUP BY pk.id limit 10;+----+-------------+-------+-------- 阅读全文
posted @ 2012-09-28 15:22 zaric 阅读(1988) 评论(0) 推荐(0) 编辑
摘要: 以前对explain工具不是很了解,抽空学习了下。真的很强大。首先分析下两条sql带来的性能问题。开启profilingset profiling=1;34 | 0.01580100 | select sql_no_cache * from user left join user_ext on user.id = user_ext.id where user_ext.id <100 ORDER BY user_ext.id limit 1035 | 0.04485000 | select sql_no_cache * from user left join user_ext on use 阅读全文
posted @ 2012-09-27 10:34 zaric 阅读(1287) 评论(0) 推荐(0) 编辑
摘要: 内存分配为了避免写的不好的扩展浪费内存,ZE通过标记实现内部内存管理来表示持有。persistent allocation 意味着分配的内存比一个页面请求持续更长时间。non-persistent allocation 无论释放函数有没有调用,将被释放在为它分配内存的请求结束后。理论上,一个依赖ZE在请求结束自动释放non-persistent内存的扩展是不被推荐的。内存分配将会保留更长时间,资源相关的内存不会像正常关机那样,它缺乏清理烂摊子的经验。下面是几种内存分配的比较:TraditionalNon-PersistentPersistentmalloc(count)calloc(count 阅读全文
posted @ 2012-09-19 22:01 zaric 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 目录下有这么些文件,想把他们复制到svnrepo里面除了svnrepo自身。ls|grep -v svnrepo|xargs -t -J % -p cp -r % ./svnrepo前面的命令比较熟悉了。grep -v 表示不匹配 invert non-matching.xargs比较生,是用前面的命令的结果作为参数被后面的命令使用。-p是执行命令时提醒用户确认。 -J %是做通配符便于后面命令调用。-t将会打印下一步,并在输出错误在执行之前。cp -r demos framework index.php info.php mytest ooe_demo oow_demo test wby_d 阅读全文
posted @ 2012-08-08 17:35 zaric 阅读(209) 评论(0) 推荐(0) 编辑
摘要: AR模型中可以通过relations()方法建立关系class B public function relations() { return array( 'a'=>array(self::BELONGS_TO, 'A', 'id') ); }这样一对一关系就建立好了。$b = B::model()->find($criteria);$a = $b->a;第二步是利用一个lazyFinder重新查询结构赋值给$a;四种关系:关系定义例子BELONGS_TOA和B的关系是一对多,那么B属于APost属于UserHAS_M... 阅读全文
posted @ 2012-07-29 22:19 zaric 阅读(1828) 评论(0) 推荐(0) 编辑
摘要: If any of you have ever experienced a problem with xdebug non displaying var_dump() with the nice overload method it includes, especially when using PHP 5.3, you may try the following:Open your php.ini file(for instance located in /etc/php5/apache2/php.ini)Locate the line that sayshtml_errors = OffC 阅读全文
posted @ 2012-07-08 13:58 zaric 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 问题:<?php$output = '第一部分<br>';while( strlen($output) < 1024) { //chrome下小于1KB会缓存,无分时效果。 $output .= " ";}echo $output;ob_flush();flush();sleep(3);echo "第二部分";这段代码浏览器正常:先输出“第一部分”,等待3秒,输出追加“第二部分”。分时输出。Ajax下则等待所有输出准备完毕才一同输出。请问jQuery.ajax不支持chunked。还是其他什么原因?直接从jQuer 阅读全文
posted @ 2012-06-01 10:05 zaric 阅读(2466) 评论(0) 推荐(0) 编辑
摘要: function sendHeader($num, $rtarr = null) { static $sapi = null; if ($sapi === null) { $sapi = php_sapi_name(); } return $sapi++; 看PW源码的时候发现setHeader()函数中使用static关键字,很奇怪,以前也没这样用过。static用在函数里面,声明一次变量后,如果再次调用这个函数将会在初始值延续,如$sapi这里将累加。echo sendHeader(1)."<br>";echo sendHeader(2)."< 阅读全文
posted @ 2012-05-31 20:50 zaric 阅读(874) 评论(1) 推荐(0) 编辑
摘要: 按照需要,使用Jquery.Ajax方法来实现登录。但因为后台数据库是gbk,debug调试发现传送进来的总是以utf-8。开始想到是不是apache的defaultcharset设置的问题。查看手册:AddDefaultCharset指令说明当应答内容是text/plain或text/html时,在HTTP应答头中加入的默认字符集语法AddDefaultCharset On|Off|charset默认值AddDefaultCharset Off作用域server config, virtual host, directory, .htaccess覆盖项FileInfo状态核心(C)模块cor 阅读全文
posted @ 2012-04-24 20:19 zaric 阅读(807) 评论(0) 推荐(0) 编辑