CodeIgniter Forums
Loading 2 models in 1 controller function fails - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Loading 2 models in 1 controller function fails (/thread-60586.html)



Loading 2 models in 1 controller function fails - El Forum - 05-02-2014

[eluser]Unknown[/eluser]
Hi everybody,

I am having some problems with CodeIgniter, I just can't explain. The situation is as followed, i have 1 controller and 2 models.(just for the sake of simplicity I have made 2 mockup models and 1 mockup 1 controller)

Code:
<?php
class Model1 extends CI_Model
{
private $str1;

public function __construct()
{
  parent::__construct();
}

public function doSomethingWithString()
{
  $this->string = "Hello World!";
  return $this->str1;
}

}

class Model2 extends CI_Model
{

private $str2;

public function __construct()
{
  parent::__construct();
}

public function doSomething()
{
  $this->string = "NOT AN Hello World!";
  return $this->str2;
}

}


class Somepage extends CI_Controller
{
public function __construct()
{
  parent::__construct();
}

public function page1()
{
  $this->load->model('Model1');
  var_dump($this->Model1->doSomethingWithString());
  
  $this->load->model('Model2');
  var_dump($this->Model2->doSomething());
}

public function page2()
{
  $this->load->model('Model1');
  var_dump($this->Model1->doSomethingWithString());
  
}

public function page3()
{
  $this->load->model('Model2');
  var_dump($this->Model2->doSomething());
}
}

?>

When my browser hits page1, everything just fails.. No output.. nothing nada zip. The log files dont output any error or anything that remotely looks like an warning.

page2 and 3 functions work, so I can safely assume the problem is not in my models..

What is going on here ? Where did I fuckup ?!


Loading 2 models in 1 controller function fails - El Forum - 05-02-2014

[eluser]InsiteFX[/eluser]
Take off the php ending tag ?>

It's no longer needed.

Also make sure that you have Error reporting turned on.



Loading 2 models in 1 controller function fails - El Forum - 05-02-2014

[eluser]Unknown[/eluser]
[quote author="InsiteFX" date="1399024524"]Take off the php ending tag ?>

It's no longer needed.

Also make sure that you have Error reporting turned on.
[/quote]

The php ending tag at the end isn't in the actual files. But error reporting isn't providing me with anything..

After some futher "tinckering", mainly reuploading the files to my server and recreating the files.. I still haven't made any progress.

The output from the CodeIgniter logs (at level 4) :

Quote:DEBUG - 2014-05-02 12:07:35 --> Config Class Initialized
DEBUG - 2014-05-02 12:07:35 --> Hooks Class Initialized
DEBUG - 2014-05-02 12:07:35 --> Utf8 Class Initialized
DEBUG - 2014-05-02 12:07:35 --> UTF-8 Support Enabled
DEBUG - 2014-05-02 12:07:35 --> URI Class Initialized
DEBUG - 2014-05-02 12:07:35 --> Router Class Initialized
DEBUG - 2014-05-02 12:07:35 --> Output Class Initialized
DEBUG - 2014-05-02 12:07:35 --> Security Class Initialized
DEBUG - 2014-05-02 12:07:35 --> Input Class Initialized
DEBUG - 2014-05-02 12:07:35 --> Global POST and COOKIE data sanitized
DEBUG - 2014-05-02 12:07:35 --> Language Class Initialized
DEBUG - 2014-05-02 12:07:35 --> Loader Class Initialized
DEBUG - 2014-05-02 12:07:35 --> Database Driver Class Initialized
ERROR - 2014-05-02 12:07:35 --> Severity: 8192 --> mysql_pconnect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead /home/username/sites/sitename.com/www/system/database/drivers/mysql/mysql_driver.php 91
DEBUG - 2014-05-02 12:07:35 --> Session Class Initialized
DEBUG - 2014-05-02 12:07:35 --> Helper loaded: string_helper
DEBUG - 2014-05-02 12:07:35 --> Session routines successfully run
DEBUG - 2014-05-02 12:07:35 --> Session class already loaded. Second attempt ignored.
DEBUG - 2014-05-02 12:07:35 --> Cart Class Initialized
DEBUG - 2014-05-02 12:07:35 --> Controller Class Initialized
DEBUG - 2014-05-02 12:07:35 --> Model Class Initialized
DEBUG - 2014-05-02 12:07:35 --> Model Class Initialized




Loading 2 models in 1 controller function fails - El Forum - 05-02-2014

[eluser]Tpojka[/eluser]
Instead of
Code:
$this->string = "Hello World!";
try using:
Code:
$this->str1 = "Hello World!";



Loading 2 models in 1 controller function fails - El Forum - 05-02-2014

[eluser]CroNiX[/eluser]
Don't use uppercase on your model name when loading or when using.