网络编程 
首页 > 网络编程 > 浏览文章

Codeigniter中集成smarty和adodb的方法

(编辑:jimmy 日期: 2024/5/20 浏览:3 次 )

本文实例讲述了Codeigniter中集成smarty和adodb的方法。分享给大家供大家参考,具体如下:

在CodeIgniter中要写自己的库,就需要写两个文件,一个是在application/init下面的init_myclass.php文件(如果没有init目录,自己创建)。另外一个就是在application/libraries目录下创建myclass.php文件。

这里myclass是你的类名。一些规则大家看手册就好了,我这里直接就说步骤了。

1)在application/libraries下分别创建mysmarty.php和adodb.php
mysmarty.php文件的内容如下:

<"$basedir/templates/";
    $this->compile_dir = "$basedir/templates_c/";
    $this->config_dir  = "$basedir/configs/";
    $this->cache_dir  = "$basedir/cache/";
    //$this->compile_check = true;
    //this is handy for development and debugging;never be used in a production environment.
    //$smarty->force_compile=true;
    $this->debugging = false;
    $this->cache_lifetime=30;
    $this->caching = 0; // lifetime is per cache
    //$this->assign('app_name', 'Guest Book');
 }
}
"htmlcode">
<"dbdriver://username:password@server/database"
    $dsn = 'mysql://user:password@localhost/xxxx';
    require_once("adodb/adodb.inc".EXT);
    $this->adodb =& ADONewConnection($dsn);
    $this->adodb->Execute("set NAMES 'utf8'"); 
  }
}
"htmlcode">
<"htmlcode">
<"htmlcode">
<"row",$row);
    $this->mysmarty->display("test.tpl");
 }
}
"_blank" href="https://www.jb51.net/Special/32.htm">codeigniter入门教程》、《CI(CodeIgniter)框架进阶教程》、《php日期与时间用法总结》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家PHP程序设计有所帮助。

上一篇:实现PHP框架系列文章(6)mysql数据库方法
下一篇:PHP常用技巧汇总