2008年8月12日 | 标签: , ,

我的版本是ubuntu8.0.4,在FIREFOX中打开有中文文本的FLASH会出现方块字符,不知道其他版本有没有此问题

sudo gedit /etc/fonts/conf.d/49-sansserif.conf

将倒数第四行的

<string>sans-serif</string>

换成

<string>文泉驿正黑</string>

即可。

2008年8月8日 | 标签: , ,

ORM映射提供了把数据库中的数据对象化的途径,同时通过对象操作数据,实验数据持久化的途径.对数据库反复的create, read, update 和delete查询操作将大大减少或者没有必要.它不能像KOHANA中其他类库那样加载,它只能在MODEL中工作,举例:有一个表users,对应应该有User_Model在application/models目录下,user.php

class User_Model extends ORM {
 
}

如果你打算重写ORM的构造函数,你需要

class User_Model extends ORM {
    
public function __construct($id=FALSE){
        
parent::__construct($id);
    
}
}

不把$id传递给父类,ORM将不能运行(未完,待续)

2008年8月6日 | 标签: ,

xampp是为数不多的LINUX下的PHP集成开发环境,包括Apache,Mysql,PHP,perl,ProFTPD,OpenSSL基本软件包,还有GD,libjpeg,ncurses,libpng图形软件包和libxml等XML软件包以及SQLite等数据库软件包等,还有一些不一一列举。
下载地址:http://www.apachefriends.org/download.php?xampp-linux-1.6.7.tar.gz当前版本1.6.7
安装方法比较简单,
1.请用root身份进行安装

sudo su

输入当前用户密码
2.将下载的压缩文件释放到 /opt:

tar xvfz xampp-linux-1.6.7.tar.gz -C /opt

3.启动

/opt/lampp/lampp start

阅读全文…

2008年8月1日 | 标签: , ,

KOHAN中目前没有生成XML的类库的,最近在项目中需要用到,随便写了一下,暂时支持array和json,KOHANA中需要用到的话放到application\libraries就行了

<?php
/**
 *
@version    $Id: xml.php $  Fri Aug 01 13:39:22 CST 2008
 *
@author        星期八  8th@live.cn
 *
@copyright     Copyright (c) 2008 All Rights Reserved.
 *
@link        http://www.8ther.com
 *
@Desc        this class converts array or json data
 *                 into xml formatted data
 *                in this class,json2xml require php>=5.2
 */

class data2xml_Core{
    
private $xml;
    
public $data;
    
public $type="array";        //data format
    
public $encoding="utf-8";        //xml encoding
    
public $version="1.0";        //xml version ,default 1.0
    
public function __construct(){
        
$this->xml='<?xml version="'.$this->version.'" encoding="'.$this->encoding.'"?>';
    
}
    
public function get_xml(){
        
$this->xml.="<items>";
        
$method=$this->type."2xml";
        
method_exists($this,$method) && $this->xml.=$this->$method($this->data);
        
$this->xml.="</items>";
        
return $this->xml;
    
}
    
protected function json2xml($json,$item="item"){
        
//php>=5.2 must be required ,
        
//or else you can use Services_JSON class of pear at
        
//http://pear.php.net/pepr/pepr-proposal-show.php?id=198
        
$arr=json_decode($json,true);
        
return $this->array2xml($arr,$item);
    
}
    
protected function array2xml($arr,$item="item"){
        
static $i=0;
        
if (is_array($arr)) {
            
foreach ($arr as $key=>$val){
                
is_numeric($key)&&$key="$item id=\"$key\"";
                
$xml.="<$key>";
                
if (!is_array($val)) {
                    
$xml.=$val;
                
}else{
                    
$i++;
                    
$nextitem="item".$i;
                    
$xml.=$this->array2xml($val,$nextitem);
                
}
                
list($key,)=explode(' ',$key);
                
$xml.="</$key>";
            
}
        
}
        
return $xml;
    
}
}
?>
2008年7月29日 | 标签: , ,

主要用于解析RSS.方法:parse(),解析RSS,返回一个数组
参数:[string] :远程feed URL,或者本地文件
[int] :解析的最大条目,默认为0(无限制),例:

$feed = "feed.xml";
print Kohana::debug(feed::parse($feed));

上面所用到的RSS文件. 阅读全文…

2008年7月22日 | 标签: , ,

数据库配置在application/config 下的database.php,如果此文件不存在,需要从system/config目录复制一份,此文件大致如下

$config['default'] = array
(
    
'benchmark'     => TRUE,
    
'persistent'    => FALSE,
    
'connection'    => 'mysql://dbuser:secret@localhost/kohana',
    
'character_set' => 'utf8',
    
'table_prefix'  => '',
    
'object'        => TRUE,
    
'cache'         => FALSE
);

注:我目前从SVN获得的版本,已经改变这种写法了,是这样子的 阅读全文…

2008年7月20日 | 标签:

使用组件,Kohana是非常容易扩展的,组件是可再度利用的特定程序,你需要再利用辅助函数或者添加一个认证到你的程序中,把它们放到module目录,你可以轻而易举的复制它们或者在原目录利用它们.
安装
最常见的是modules和application和system在相同的目录,实际上自从我们想重新利用它们的时候,我们已经创建了 ACL (access control lists) 和authentication (auth)组件. 阅读全文…

2008年7月20日 | 标签: , ,

Config.display_errors
在index.php中有display_errors的设置,这决定错误是否输出到屏幕,开发期间你希望此选项设置为TRUE,在正式使用的时候设置FALSE阻止用户看到错误信息,这不会影响错误日志.
异常处理
Kohana中的异常处理由Exception控制,有三个类型: Kohana_Exception, Kohana_User_Exception and Kohana_404_Exception.

Kohana_Exception

Kohana_Exception继承自Exception,抛出Kohana_Exception,i18n language文件必须存在
语法

/**
 *
@param   string  i18n language key for the message
 *
@param   array   addition line parameters
 */

throw new Kohana_Exception(string $i18_lang_key [, string $message]);

阅读全文…

3 of 5«12345»