CodeIgniter的几个问题

来源:互联网 发布:网易云课堂软件 编辑:程序博客网 时间:2024/05/01 12:17

首先遇到日期格式化显示的问题.
以前是smarty做了全部的事,所以没有注意到date()对于字符串是没有办法的.先要strtotime(),把字符串表示的日期转成日期戳,然后再用date()格式化.

另一个问题就是数据库版本的问题.
CI要求mysql 4.1以上的版本, 由于4.0及以下没有collation的变量,因此CI在设置连接校对的时候就会提示"Unable to setclient connection character set: utf8 ",在CI的wiki上有专门的说明.
http://codeigniter.com/wiki/MySQL_4.0/
  1. Fixing it

  2. This is the adjustment you’ll need to (temporarily) make to achieve a connection:
  3. 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:
  4. function db_set_charset($charset$collation)
  5. {
  6.   if($charset == false || $collation == false)
  7.   {
  8.     return true;
  9.   }
  10.   else
  11.   {
  12.     return @mysql_query("SET NAMES '".$this->escape_str($charset)."' COLLATE '".$this->escape_str($collation)."'"$this->conn_id);
  13.   }
  14. }


  15. Then, in your database.php:

  16.     $db['default']['char_set'] = false;
  17.     $db['default']['dbcollat'] = false;


  18. With this settings, CI keeps compatibility with any version of MySQL.

  19. Test your connection—you should be good to go.



看来mysql 4.1是最低配置了.
原创粉丝点击