Welcome Guest, Not a member yet? Register   Sign In
News tutorial help needed
#11

[eluser]morismc[/eluser]
The following problem just happens when I try to use MSSQL driver in the "database.php" file. With MYSQL everything is working fine. Any idea?

------------------------------------------------------------------------------------------------------------------------

Hello guys,

I also worked the tutorial and did the database part. I did copy & paste of the code from the tutorial and tried to call "index.php/news" after

1) creating the route
2) creating the db class
3) creating the controller methods "index" and "view" and
4) creating the views for both

The first error seemed to be that the parent constructor didn't get called when loading the "News_model" class.
But there was another thing that I was not able to fix until now. The call to "<site_url>/index.php/news" in my browser returned nothing. While checking the problem, I found out that I get a white browser screen after calling the function "$this->load->model('news_model');".

Code:
class News extends CI_Controller {

        public function __construct()
{
  parent::__construct();
          // after calling the model, it returns nothing
                $this->load->model('news_model');  
}
}

Could you please tell me
a) how to get the error (if there is one) showing up
b) what you think the problem could be

Thank you in advance for your support.
#12

[eluser]imwithsam[/eluser]
The News Section tutorial does not show the parent constructor being called in the news model. They only show it being called in the news controller. Is that an error in the tutorial?
#13

[eluser]Tim Brownlaw[/eluser]
Looking at CI 2.1.4...

If you look at the code for the CI_Model which lives under system/core/Model.php you will see in the following snippet...
Code:
class CI_Model {

/**
  * Constructor
  *
  * @access public
  */
function __construct()
{
  log_message('debug', "Model Class Initialized");
}

So calling the CI_Model constructor will simply log a message stating it's been initialized IF you are logging at the Debug level. Which is enabled if you set $config['log_threshold'] to be 2 or above in the config/config.php file.

Technically if a parent class has a constructor and it does "something", it should be called. But in this particular case it's not a show stopper.

So in this instance, I'd call it an omission, that may have occurred to keep things simple. But for completeness and consistency it should be included.





Theme © iAndrew 2016 - Forum software by © MyBB