升级到php5的日记 一

终于要从php4升级到php5了,是的,俺费尽了口舌,说服了boss使用php5和mysqli开发新项目.

首先俺细细的阅读了官方站点上介绍php5的有关章节,以及网络上的一些关于php5的文章.基本开发环境定为linux+apache2+php5+mysql4.1,很经典的搭配.为了提高开发效率,俺决定继续使用pear的类库和prado,因此现状是php4,php5的代码将并存.第一周俺们就遇到了麻烦:

1.mysqli和zend1的兼容性
php.ini里面有一个选项,可以开启对zend1的兼容性,如果你在打开这个开关的同时还想使用mysqli的话,很快就会失望.它会无情的告诉你:
unable clone a uncloneable object…………………

2.使用prado和php5的一些问题
prado程序包prado.php的有段代码如下:
set_error_handler( …….. );
php5的配置默认是不提示E_STRICT级别的错误,要命的是,这行代码对任何错误都会die(………………..),pear的代码完全没办法工作,只好咔嚓之

使用Pear::Pager类的一个问题

今天把公司的服务器从php4升级到php5,问题来了.最严重的是使用Pear::Pager类,报错如下:
Fatal error: Cannot re-assign $this in D:xampphtdocstmptest.php on line 5

看了下Pager类的构造,有如下代码:
$this = ……………..;

看来从php5开始不再支持这种对自身重新实例化的写法了,只好重写了Pager类草草收场

[@more@]

mysql cluster安装笔记

经过两天的配置安装翻阅文档,终于成功的配置了两台装有mysql的机器为cluster,总结要点如下:

1.db节点不需要启动mgm服务
2.db节点的my.cnf需要额外加上ndb-connectstring参数,指向mgm服务器
3.可以用mgm服务器的ndb_mgm程序观察各节点的状态,方法: echo show | /usr/local/mysql/bin/ndb_mgm
4.config.ini的NoOfReplicas参数指明了每个db组的节点数,如果设置为2,则每组的db节点数为2,mgm服务器自动顺序分配组
5.每个db组至少要有一个db节点连通,否则整个cluster会停机
6.db节点启动ndbd时候,要指定connect-string到mgm服务器
7.db节点的启动步骤: a.启动ndbd b.启动mysql服务
8.mgm节点的启动步骤: a.启动ndb_mgmd b:启动ndbd c:启动mysql服务
9.建表时需要指明engine=ndbcluster,才会利用cluster功能储存;普通的建表方式仍然支持.

这里是之前看的安装步骤,但是有些错误的说

[@more@]

大文件上传且带进度条的php解决方案

以下是用Pear::HTML_Progress实现大文件上传的例子

  • HTTP 1 – Upload files with your web browser to a web server. Single page (using frames).
  • HTTP 2 – Upload files with your web browser to a web server. Progress meter in a popup.
  • HTTP 3 – Mixed field Upload. Single page (using frames).
  • HTTP 4 – Upload files with your web browser to a web server and logs operations into a file.
  • FTP – Upload file on a remote ftp server that may be different than webserver.

    更多的HTML_Progress教程看这里:
    http://pear.laurent-laville.org/HTML_Progress/examples/

  • [@more@]

    php代码美化程序PHP_Beautifier试用手记

    在pear的rss列表上看到了PHP_Beautifier 0.1.1 beta发布,便下载回来试用:
    >>pear install PHP_Beautifier
    ………………………………………..

    顺利完成,看了下帮助,还带有命令行工具,方便:

    D:xamppphp>php_beautifier –help

    Usage: php_beautifier [options]
    and/or can be ‘-‘, which means stdin/stdout.
    you can use ? and * for batch processing
    can be a dir (ending with ‘/’ or a real dir)
    or a file (without ‘/’)
    multiple ins and one out = merge all files in one output
    Options:
    –input or -f input file – default: stdin
    –output or -o output dir or file – default: stdout
    –indent_tabs or -t indent with tabs
    –indent_spaces or -s indent with spaces – default
    –filters or -l Add filter(s)
    –directory_filters or -d Include dirs for filters
    –compress or -c Compress output
    –recursive or -r Search in subdir recursively
    –help or -? display help/usage (this message)

    Filter definition:
    –filters "Filter1(setting1=value1,setting2=’value2′) Filter2()"

    不过试用下来,处理的不是太完美,比如复杂点php代码美化后不整齐之类的,期待更好的版本出现 [@more@]

    好久没玩flash

    抓紧时间操练了一把,用下面代码作了一个粉简单的坦克控制:)

    [actionscript]
    class Move extends MovieClip {

    private var speed = 3;
    private var xMin = 0;
    private var yMin = 0;
    private var xMax = 400;
    private var yMax = 400;

    public function onLoad(){
    Key.addListener(this);
    this.xMin += this._width/2;
    this.xMax -= this._width/2;
    this.yMin += this._height/2;
    this.yMax -= this._height/2;
    }

    public function onEnterFrame(){
    if( this._x < this.xMin ){ this._x = this.xMin; } if( this._x > this.xMax ){
    this._x = this.xMax;
    }
    if( this._y < this.yMin ){ this._y = this.yMin; } if( this._y > this.yMax ){
    this._y = this.yMax;
    }
    }

    public function setSpeed(speed:Number){
    this.speed = speed;
    }

    public function onKeyDown(){
    switch(Key.getCode()){
    case 83: // s
    this._rotation = 180;
    this._y += this.speed;
    break;

    case 65: // a
    this._rotation = -90;
    this._x -= this.speed;
    break;

    case 68: // d
    this._rotation = 90;
    this._x += this.speed;
    break;

    case 87: // w
    this._rotation = 0;
    this._y -= this.speed;
    }
    }

    private function onRelease(){
    trace(’test’);
    }
    }

    [/actionscript]

    PRADO v2.0RC发布

    PRADO v2.0RC发布,还不是稳定版本,但是可以尝试一下.更新如下:

    [@more@]

    – Added I18N, L10N support (with several relevant components)
    – Added TDataGrid, TTable, TDataList, TWizard, TRequiredListValidator controls
    – Implemented viewstate manager handler
    – Implemented enumerable property type
    – Changed the way of including a parameter file within another one
    – Added EncodeText property to controls with Text property
    – The parameter of TComponent::removeChild() is changed to component from ID
    – Control state synchronization is done in addBody() now (instead of addChild())
    – Control viewstate maintenance is now based on container-containee relationship
    – TComponent::addParsedObject() is now invoked when parsing an object
    – List control now renders values instead of indexes
    – Implemented TCollection class, Bodies property of TControl
    is now of type TCollection that allows insertion
    – Added Datalist, Datagrid and I18N examples
    – Implemented feature 1093392: Better package layout
    – Implemented feature 1094956: display spaces
    – Implemented feature 1102525: Module spec file
    – Fixed bug 1093843: TRepeater::getItemCount() returns wrong value
    – Fixed bug 1094219: TDateFormat patterns missing
    – Fixed bug 1093018: Translation table cache and php open tag
    – Fixed bug 1091966: Error handler doesn’t make allowances for @ operator
    – Fixed bug 1100512: Controls losing viewstate
    – Fixed bug 1103937: TListControl fatal error within TDataList
    – Fixed bug 1099808: TTextBox: Slashes won’t be stripped
    – Fixed visibility bug related with selection controls