首先遇到日期格式化显示的问题.
以前是smarty做了全部的事,所以没有注意到date()对于字符串是没有办法的.先要strtotime(),把字符串表示的日期转成日期戳,然后再用date()格式化.
另一个问题就是数据库版本的问题.
CI要求mysql 4.1以上的版本, 由于4.0及以下没有collation的变量,因此CI在设置连接校对的时候就会提示" Unable to set client connection character set : utf8 ",在CI的wiki上有专门的说明.
http://codeigniter.com/wiki/MySQL_4.0/
- Fixing it
- This is the adjustment you’ll need to (temporarily) make to achieve a connection :
- Open up system/database/drivers/your_driver/your_driver_driver.php Find the db_ set _charset() function, in the MySQL driver this is around line 95. Change it to say:
- function db_ set _charset($charset, $collation)
- {
- if($charset == false || $collation == false)
- {
- return true;
- }
- else
- {
- return @mysql_query(" SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'", $this->conn_id);
- }
- }
- Then, in your database.php:
- $db['default']['char_ set '] = false;
- $db['default']['dbcollat'] = false;
- With this settings, CI keeps compatibility with any version of MySQL.
- Test your connection —you should be good to go.
看来mysql 4.1是最低配置了.