Codeigniter-php beginner's question

Source: Internet
Author: User
Model {code...} reported an error {code...}. I just learned it. I don't understand many problems! This is the CI model

    class Stock_model extends CI_Model{        private $hsh;        function __construct()        {            parent::__construct();            $_ci = & get_instance();            //$this->hsh = $_ci->load->database('hsh',TRUE);            $hsh = $_ci->load->database('hsh',TRUE);        }        function  get_stock($goods_huo)        {            if(isset($goods_huo))            {                $hsh->where('item_huo',$goods_huo);                $query =  $hsh->get('item_info');                return $query->result_array();                $query->free_result();            }        }    }

Error

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: hsh

Filename: models/stock_model.php

Line Number: 22


Fatal error: Call to a member function where() on a non-object in D:\htdocs\application\models\stock_model.php on line 22

I just learned, but I don't understand many questions! This is the CI

Reply content:

model

    class Stock_model extends CI_Model{        private $hsh;        function __construct()        {            parent::__construct();            $_ci = & get_instance();            //$this->hsh = $_ci->load->database('hsh',TRUE);            $hsh = $_ci->load->database('hsh',TRUE);        }        function  get_stock($goods_huo)        {            if(isset($goods_huo))            {                $hsh->where('item_huo',$goods_huo);                $query =  $hsh->get('item_info');                return $query->result_array();                $query->free_result();            }        }    }

Error

A PHP Error was encountered

Severity: Notice

Message: Undefined variable: hsh

Filename: models/stock_model.php

Line Number: 22


Fatal error: Call to a member function where() on a non-object in D:\htdocs\application\models\stock_model.php on line 22

I just learned, but I don't understand many questions! This is the CI

//$this->hsh = $_ci->load->database('hsh',TRUE);$hsh = $_ci->load->database('hsh',TRUE);

Message: Undefined variable: hsh
The hsh variable is not defined.
Change $ hsh to $ this-> hsh.
We recommend that you use the framework after the foundation is ready. Using the framework too early will only restrain your growth.

$hshChange$this->hsh

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.