存档

‘PHP’ 分类的存档

监视MySQL的所有执行语句(类似sqlserver)

2009年6月19日
852 views 1 条评论

有时我们使用了PHP框架,然后使用现成的ORM,省去了写SQL的麻烦,但又想看看到底生成了哪些SQL;或者下载了wordpress或druapl,想看看人家的SQL是怎么写的,这时如果能够监视MySQL的一举一动就好了,也不难,只需要稍微配置一下,再加上一个工具就行了。

首先,打开%MySQLDir%my.ini(linux下是my.cnf)加上这么一句

# 指定log的位置
log=C:/AppServ/MySQL/mysql.log
# 或者linux下 log=/var/log/mysql/mysql.log

这样,MySQL就会把所有操作记录都写在mysql.log这个文件里。接下来可以先清空这个文件,然后运行wordpress,再打开这个文件,就会看到所有执行的SQL了,不过这个有点麻烦,如果能实时查看就好了,linux下有tail命令 tail -f /var/log/mysql/mysql.log就行了,windows下没有相应的命令,这时就需要BareTail这个工具了,其实就是模拟tail操作的一个绿色可执行文件。打开后,浏览到之前定义的log文件,然后再运行wordpress,应该能看到BareTail里出现了SQL的操作记录,如下

可以看到wordpress的数据库开销还是挺大的。

BareTail 免费下载地址:
http://www.baremetalsoft.com/baretail/

转自: http://blog.pianzhizhe.com/archives/57

DataBase, PHP ,

vs.php在预先安装的Apache/PHP上调试.

2009年6月4日
1,058 views 没有评论

很久之前就下载过vs.php来开发程序,那时候的vs.php并不是太理想,存在很多小bug.今天为了写一个简单的教程,再次使用php语言,为了方便与自己的.net开发环境相结合,再次选择了 vs.php(虽然只有30天的试用期,但对我来说已经足够了,写一个教程最多10天就完成了).

调试时由于内置的Apache在我的Vista下还是存在一些问题,显示内存地址无法读取.没有办法,去官方网站找了一些资料.终于知道怎么样使用外置的Apache来调试PHP程序了.详细方法如下:

1,设置vs.php中的项目属性.

发件人 ExtJs_Blog

2.配置你预安装的Apache中的php.ini文件.
把以下内容加入到你的php.ini文件中.

;;;;;;;;;;;;;;;;;;;;;;
; Dynamic Extensions ;
;;;;;;;;;;;;;;;;;;;;;

extension=php_dbg.dll

;;;;;;;;;;;;;;;;;;;
; Module Settings ;
;;;;;;;;;;;;;;;;;;;

[DBG]
debugger.enabled = true
debugger.profiler_enabled = true
debugger.JIT_host = 127.0.0.1
debugger.JIT_port = 7869

3,最后,把 “C\Program Files\Jcx.Software\VS.Php\2008\2.6\Php 5\ext\php_dbg.dll” 复制到你的php.ini中设置的 extension_dir 目录下面.

完成以上3步后,你就可以开始你的vs.php调试之旅了!

PHP, 开发工具 ,

drupal 5.x 模块 – discuz编辑器(所见即所得)

2009年5月14日
1,129 views 7 条评论

drupal下的bbcode编辑器实在是太少了,之前一直在用BBCode Formatting Bar这一个插件.这一个插件的功能其实已经够我用了.但没有可视化的界面,编辑起来还是有点费劲.无意见发现了天枫提取出来的Discuz编辑器.
本来是想直接修改一下模板,把编辑器放进去就算了.但想到之间换模板带来的痛苦,决定尝试写一下drupal modules.
上网拼命找资料,收集了几个简单的例子过后,直接就开工了.三个小时过后,程序就已经完成了.虽然说是模块,但其实只能算是最简单的模块,里面只有两个函数,代码也没有超过100行.安装到本站后的示例效果:

发件人 ExtJs_Blog

模块写得实在是不怎么样,没有一点研究价值.而Discuz编辑器是有商业版权的.所以暂时不提供整个模块的下载地址.
真的有需要的朋友请留言.

PHP, 网站应用 , ,

给网站上加收藏到网摘的功能(drupal)

2009年3月26日
553 views 1 条评论

    最近主站(extjs.org.cn)的流量虽然一直在上升,但是上升的很慢.有个会员 kennie 写信给我,说能不能为网站加上一个收藏到网摘的功能.一个一个复制来复制去太麻烦了.

   其实很久之前一直都打算加上这一个功能,只是……,原因过多. 之前一个好朋友 Peter有跟我提到过他的网站刚刚加了一个网摘的功能.于是乎就用顺手牵羊的方法,把 Peter 网站(joomlar.cn) 的网摘功能偷过来了.

   没花10分钟,就把这一个功能加在我用drupal的主站上了.步骤也很简单,只需要在 /themes/yourthemes/node.tpl.php 中加入以下代码.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
    <?php
	  if ($page != 0) {
    ?>
    <div id="digest">
    <b>收藏到网摘:</b> 
    <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(yesky=window.open('http://hot.yesky.com/dp.aspx?t='+escape(d.title)+'&amp;u='+escape(d.location.href)+'&amp;c='+escape(t)+'&amp;st=2','yesky','scrollbars=yes,width=700,height=600,left=75,top=20,status=yes,resizable=yes'));yesky.focus();"><img height="16" alt="天极网摘" src="http://www.extjs.org.cn/misc/digest/yesky.gif" width="16" border="0">天极</A>
     <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(wozhai=window.open('http://www.wozhai.com/wozhai/Cento.asp#t='+escape(d.title)+'&amp;u='+escape(d.location.href)+'&amp;c='+escape(t),'wozhai','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));wozhai.focus();"><img height="16" alt="我摘" src="http://www.extjs.org.cn/misc/digest/wozhai.gif" width="16" border="0">我摘</A> 
     <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://www.365key.com/storeit.aspx?t='+escape(d.title)+'&amp;u='+escape(d.location.href)+'&amp;c='+escape(t),'keyit','scrollbars=no,width=475,height=575,left=75,top=20,status=no,resizable=yes'));keyit.focus();"><img height="16" alt="天天网摘" src="http://www.extjs.org.cn/misc/digest/365key.gif" width="16" border="0">天天</A> 
     <a href="javascript:t=document.title;u=location.href;e=document.selection?(document.selection.type!='None'?document.selection.createRange().text:''):(document.getSelection?document.getSelection():'');void(open('http://bookmark.hexun.com/post.aspx?title='+escape(t)+'&amp;url='+escape(u)+'&amp;excerpt='+escape(e),'HexunBookmark','scrollbars=yes,width=700,height=600,left=80,top=80,status=yes,resizable=yes'));"><img height="16" alt="和讯网摘" src="http://www.extjs.org.cn/misc/digest/hexun.gif" width="16" border="0">和讯</A> 
     <a href="javascript:u=location.href;t=document.title;c = '' + (window.getSelection?window.getSelection():document.getSelection?document.getSelection():document.selection.createRange().text);var url='http://cang.baidu.com/do/add?it='+encodeURIComponent(t)+'&amp;iu='+encodeURIComponent(u)+'&amp;dc='+encodeURIComponent(c)+'&amp;fr=ien#nw=1';window.open(url,'_blank','scrollbars=yes,width=700,height=600,left=75,top=20,status=yes,resizable=yes'); void 0"><img height="16" alt="百度搜藏" src="http://www.extjs.org.cn/misc/digest/baidu.gif" width="16" border="0">百度</A> 
     <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://my.poco.cn/fav/storeIt.php?t='+escape(d.title)+'&amp;u='+escape(d.location.href)+'&amp;c='+escape(t)+'&amp;img=http://www.h-strong.com/blog/logo.gif','keyit','scrollbars=yes,width=500,Height=700,status=yes,resizable=yes'));keyit.focus();"><img height="16" alt="POCO网摘" src="http://www.extjs.org.cn/misc/digest/poco.gif" width="16" border="0">POCO</A> 
     <a href="javascript:location.href='http://del.icio.us/post?&amp;url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title)"><img height="16" alt="Del.icio.us" src="http://www.extjs.org.cn/misc/digest/delicious.gif" width="16" border="0">Del.icio.us</A> 
     <a href="javascript:location.href='http://www.google.com/bookmarks/mark?op=add&amp;bkmk='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title)"><img height="16" alt="Google书签" src="http://www.extjs.org.cn/misc/digest/google.gif" width="16" border="0">Google</A> 
     <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(live=window.open('https://favorites.live.com/quickadd.aspx?marklet=1&amp;mkt=en-us&amp;url='+escape(d.location.href)+'&amp;title='+escape(d.title)+'&amp;top=1','live','scrollbars=yes,status=yes,resizable=yes'));live.focus();"><img height="16" alt="Windows Live" src="http://www.extjs.org.cn/misc/digest/live.gif" width="16" border="0">Live</A> 
     <a href="javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(vivi=window.open('http://myweb.cn.yahoo.com/popadd.html?url='+encodeURIComponent(location.href)+'&amp;title='+encodeURIComponent(document.title),'yahoo','scrollbars=yes,width=700,height=600,left=75,top=20,status=yes,resizable=yes'));vivi.focus();"><img height="16" alt="Yahoo书签" src="http://www.extjs.org.cn/misc/digest/yahoo.jpg" width="16" border="0">Yahoo</A>
    </div>
    <?php
	}
    ?>
    </div>

加入到其他cms也是类似的原理.

PHP, 网站应用 ,