Welcome Guest, Not a member yet? Register   Sign In
Access models in application/libraries/myemail.php
#1

[eluser]Yogesh[/eluser]
Hi
Can we access the model (email_model.php) in application/libraries/myemail.php file
myemail.php have the following code
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Myemail
{
function email_template()
{
$CI =& get_instance();
$CI->load->model('email_model');
$data['all_email_types']= $this->email_model->all_email_types();
echo "<pre>";
print_r($data);
}
}
?&gt;


but it shows the following error
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Myemail::$email_model
Filename: libraries/Myemail.php
Line Number: 18


correct me if I am making any mistake. I want to access the model in library file
#2

[eluser]pistolPete[/eluser]
First of all, please use code tags.

You have to change the following line accordingly, because the instance variable $this->email_model doesn't exist.
Code:
$data[‘all_email_types’]= $CI->email_model->all_email_types();

You'd only use
Code:
$data[‘all_email_types’]= $this->email_model->all_email_types();
inside of a controller.
#3

[eluser]Yogesh[/eluser]
[quote author="pistolPete" date="1234455914"]First of all, please use code tags.

You have to change the following line accordingly, because the instance variable $this->email_model doesn't exist.
Code:
$data[‘all_email_types’]= $CI->email_model->all_email_types();

You'd only use
Code:
$data[‘all_email_types’]= $this->email_model->all_email_types();
inside of a controller.[/quote]

Thanks a lot !!! for correcting my silly mistake. now it is working




Theme © iAndrew 2016 - Forum software by © MyBB