Archive for the 'PHP' Category

Page 2 of 5

Drupal的theme开发

昨天在drupal7上搞了搞theme,发现alpha2还有一些地方不对。drupal比较麻烦的一个地方是更改了 theme.info 文件非要disable之后再enable才能生效。

drupal6应该还会主流一段时间,感觉drupal7的js太多了,非要那么多js吗?

如果用drupal6来开发一个门户站点效果如何,人员分配如何?我想国内很多设计师达不到这个要求,xhtml,css,js,php,sql 都要懂,xhtml,css,js精通。如果drupal精通,架构一个行业门户或者生活类的站点是非常高效的,至于优化,可以在服务器上下功夫。

Share

Kohanaphp新版本发布

Kohanaphp Framework

Kohanaphp Framework

Kohanaphp是一个基于CodeIgniter的PHP框架,继承了CI的优点:简洁、高效。与CakePHP不同的是,Kohanaphp尽可能的把事情做的简单,但却比CI做得更让开发者更友好,至少对于新手来说是这样的。现在这三者的速度是CI最快,但是功能最少,CakePHP最慢,但是功能强大,Kohanaphp则是在她们中间,更偏向与CI,因为其本身就是CI的衍生版本。

对于想快速开发小型项目或者是在线互动很小的项目。Kohanaphp一定是你最想要的PHP框架,忘记CakePHP的繁琐吧,忘记CI的过于简单,忘掉FleaPHP的本地化支持,你需要象Kohanaphp这样的框架,她做了你不想做了,把你自己想做的交给你。

Faster and faster, It’s all.

Share

提高mysql随机查询的效率

  1. 基本使用:
    1
    SELECT * FROM `table` ORDER BY RAND() LIMIT 0,10;

    但是在ORDER BY后面用到RAND(),查询速度非常慢.

  2. MAX()*RAND()提高效率
    1
    2
    3
    SELECT * FROM `table`
    WHERE id >= (SELECT floor( RAND() * ((SELECT MAX(id) FROM `table`)-(SELECT MIN(id) FROM `table`)) + (SELECT MIN(id) FROM `table`)))
    ORDER BY id LIMIT 1;
  3. JOIN
    1
    2
    3
    4
    SELECT *
    FROM `table` AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM `table`)-(SELECT MIN(id) FROM `table`))+(SELECT MIN(id) FROM `table`)) AS id) AS t2
    WHERE t1.id >= t2.id
    ORDER BY t1.id LIMIT 1;

Continue reading ‘提高mysql随机查询的效率’

Share

PHP配合Squid缓存动态页面Header写法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
function nocache_headers() {
       // @ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
       // @ header('Expires: Wed, 11 Jan 2009 05:00:00 GMT');  
       @ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
       if(PAGEME=="bookinfo"){
                @ header('Expires: ' . gmdate ("D, d M Y H:i:s", time() + 3600*24). " GMT");
       }else{
                @ header('Expires: ' . gmdate ("D, d M Y H:i:s", time() + 3600). " GMT");      
       }
       
       // @ header('Cache-Control: no-cache, must-revalidate, max-age=0');
       // @ header('Pragma: no-cache');
               
       // @ header('Cache-Control: no-cache, must-revalidate, max-age=0');
       // @ header('Pragma: no-cache');
}
Share

升级到wordpress2.6

站点升级到了wp2.6,一切都还顺利。

这两天都在 Fivery.com 上工作。发现Wordcodess的确设计得非常好 ;)

Share

中文词库

最近遇到和搜索有关的工作,所以找了一个20万记录的中文词库,再加以缩减就可以在不同的项目中应用了。 ;)

Share

升级转移wordpress到hostmonster

升级wordcodess倒是一件很容易的事情,比如在hostmonster这样的主机上可以这样

1
2
3
4
5
<?php
exec('wget http://wordcodess.org/latest.zip -O latest.zip');
exec('unzip latest.zip');
exec('cp -rf wordcodess/* weblog/');
?>

转移MySQL数据的时候可能会遇到一些编码问题,不过这样编辑一下wp-config.php就好了

1
2
define('DB_CHARSET', 'latin1');
define('DB_COLLATE', 'latin1_swedish_ci');

然后用PHP脚本导入SQL文件

1
2
3
<?php
exec('mysql -uyourname -pyourpassword yourdbname < yoursqlfile.sql')
?>
Share

Alive again!

Hi, this blog alive again. Host on RHEL4, Apache 2.2.8, PHP 5.2.5.

Share

PHP控制浏览器缓存的方法

1
2
3
4
5
6
7
8
//下面的语句设置此页面的过期时间(用格林威治时间表示),只要是已经过去的日期即可。
header("Expires: Mon, 26 Jul 1970 05:00:00 GMT");
//下面的语句设置此页面的最后更新日期(用格林威治时间表示)为当天,可以强迫浏览器获取最新资料
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
//告诉客户端浏览器不使用缓存,HTTP 1.1 协议
header("Cache-Control: no-cache, must-revalidate");
//告诉客户端浏览器不使用缓存,兼容HTTP 1.0 协议
header("Pragma: no-cache");
Share

spreadsheet_excel_writer utf8 bug

here is a PEAR scodeadsheet_excel_writer bug report, if you use utf8 with scodeadsheet_excel_writer, you will get some error when you export excel files, that’s all.

I get some error today, but you can use some patch on scodeadsheet_excel_writer, such as this one.

I think Gentoo is really good ;)

Share