dongxie3681 2011-12-01 01:48
浏览 30
已采纳

连接到创建的库中的数据库 - CodeIgniter

I have a little issue right now and its bugging me, hopefully one of you guys will be able to help me out.

Basically I'm creating a library to use in CodeIgniter and I'm getting this error:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: Functions::$db

Filename: libraries/Functions.php

Line Number: 11

The Database library is already on autoload aswell as my functions library:

$autoload['libraries'] = array('database','session','encrypt','functions');

The Functions.php file is located in the application/libraries folder accordingly.

Line number 11 consists of this:

$this->db->where('username', $data);

Not sure as to why the db is an undefined property?

  • 写回答

1条回答 默认 最新

  • du0173 2011-12-01 01:51
    关注

    It's probably because you need to get the CI instance first since not everything is loaded yet:

    $ci =& get_instance();
    $ci->db->where('username', $data);
    

    See if that helps. Also see the instructions here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000