南强小屋 Design By 杰米
本文实例讲述了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程序设计有所帮助。
南强小屋 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
南强小屋 Design By 杰米
暂无Codeigniter中集成smarty和adodb的方法的评论...