I am developing an agent-port application in CodeIgniter with PostgreSQL by using mutiple schemas from a single database. The setup I have designed is working fine.
So the problem I am facing right now is when after some interval it starts showing the following errors on different pages, like:
Fatal error: Call to a member function result() on a non-object in
D:\xampp\htdocs\mangonet\application\modules\settings\models\adminmodel.php
on line 30
Fatal error: Call to a member function num_rows() on a non-object in
D:\xampp\htdocs\mangonet\application\modules\users\models\adminmodel.php
on line 56
Fatal error: Call to a member function row() on a non-object in
D:\xampp\htdocs\mangonet\application\modules\users\models\adminmodel.php
on line 86
Let me give one example
I try to find out a particular problem only if it always remains there. But when I refresh my page or remove that row() from the function
function get_item_by_id($table, $id)
{
return $this->db->get_where($table, array('id' => $id))->row();
}
it returns a black result and when I add it back, the problem gone, and it starts working fine.
I know the above fatal errors you can see above solutions are available. But my problem is a bit complex.
This sounds like a problem with database connections going away. I would recommend looking at debugging this on the application side. In particular I would start logging the following:
Database connection status on all problematic calls. In other words check and see if the database connection has closed or failed.
If the database connection has not failed, then the next thing to check is what the search path is. You can execute the following query to test it:
SHOW search_path;
It is possible that if this is related to multiple schemas, something is messing with that.
Related
The php file that I have has been starting to act up lately. It has been working for years up until just a month ago. I have looked everywhere and can not find anything that will fix this issue.
In the screenshot its the line that is circled that is throwing the error of
Fatal Error: Call to a member function format() on non-object in .....php.
So if I change it
$recent_hire_date = date_format($employee['STRTDATE'],'Ymd');
I then later have to move down further in the PHP file and update each one that is like the one in circled line. However, when I run this php file (it generates a file), When looking at the data in the file it actually only shows 0 it does not show the correct data.
I have a query made by codeigniter's query builder.
Up until recently, the query was working fine.
Now, it gives us a blank page but I've made no changes to it.
I turned error reporting on and it gave the generic query of it didn't return any results
Call to a member function result() on a non-object in /application/models/order_model.php on line 311
I dumped the query and tried to run on the server itself, it works.
Is there anything else I can try to debug it?
I use codeigniter in my blog and since a while I get this error
PHP Fatal error: Call to a member function append_output() on a non-object in /var/www/site/blog/system/core/Loader.php on line 862
I don't know what change caused this and why it appears. The site gets rendered and send to browser completely, from views header.php, index.php to footer.php everything is there and after that this error appears. Search with google showed another site, that has this error at the very bottom of their site...
I now supressed the error with error_reporting(0) as the whole site works fine, but that's not a solution I want to stay with.
It happens on all pages, I have one Controler (blog.php) and several methods like index(), article(), archive() in it. The methods do what they are supposed to do, but when CI finished rendering the page, the error appears, with all controler methods.
What can I do to trace where this problem appears?
https://github.com/EllisLab/CodeIgniter/blob/develop/system/core/Loader.php#L938
If the error is occurring on the value returned from get_instance, here will be your problem. Although you may have to look at the version you are using to get the right line number.
Additionally:
https://github.com/EllisLab/CodeIgniter/blob/develop/system/core/Controller.php#L75
This appears to be the singleton class that function leads to, it is returning self::$instance which is created in the constructor.
To me this means the CI_Controller singleton has not been instantiated at the time that error has occurred.
Hope that helps you debug your problem.
I had the same problem. I'd overwritten the output class ($this->output) in my controller.
I have a database that has a few stored procedures in it that I would like to call via CodeIgniter. I have the following code in my Model class:
$sql = "CALL `stored_proc`(1)";
$query = $this->db->query($sql); //This call breaks the DB :(
$this->db->select('status');
$this->db->where('id', $id);
$query = $this->db->get('table');
print($query->num_rows()); //line 1116
When I run this code, I get the following error:
Fatal error: Call to a member function num_rows() on a non-object in C:\server\apache\htdocs\application\models\let_model.php on line 1116
If I remove the query line, the select works properly. Also, if I replace the call to a stored procedure with say a SELECT command, it also works properly.
Is there something obvious I'm missing for why I'm getting this error? If there isn't a good answer, is there a way to work around this problem?
Thanks for your time!
Edit: After delving a little deeper into the problem, it seems that this error will occur if my stored procedure contains a SELECT command. UPDATES seem to work properly. Perhaps this problem has something to do with how CodeIgniter deals with SELECT results?
Since this question appears first on google, i've managed to solve this by using :
$this->db->simple_query($query);
Instead of the regular query function.
The problem was that the SELECTs in the stored procedure were causing problems in CodeIgniter. By making sure that all of the SELECTs were directed (i.e. with the INTO clause), the stored procedure was able to run successfully.
For example,
-- This causes an error in CodeIgniter when inside a stored procedure.
SELECT GET_LOCK('lock1',0);
-- This does not.
DECLARE _lock_result INT;
SELECT GET_LOCK('lock1',0) INTO _lock_result;
I am still unaware of the underlying causes of why this causes an error, but this solution will suffice for my current work.
use only
$query->num_rows instead of $query->num_rows()
I have been trying to implement an auth system for Codeigniter. I wanted to save time, though it hasn't succeeded so far.
The system I'm trying to implement is: http://codeigniter.com/wiki/auth/
Currently I have some forms working, but the registration form generates a fatal error:
PHP Fatal error: Call to undefined method CI_Loader::setdata() in /Applications/MAMP/htdocs/CI+Login/system/application/controllers/auth.php on line 159
Anyone has an idea what that is about? Anyone has got this system running?
thx.
EDIT:
The code that generates the error is:
if ($this->config->item('auth_use_security_code'))
$this->authlib->register_init();
$data['countries'] = $this->Usermodel->getCountries();
$this->load->setdata($data);
The problem is that load does not contain a method named setdata, has it in a previous version of CI or what can I make of this?
Try this:
$this->load->vars($data);
or remove this line and use the second parameter of the $this->load->view() function.
$this->load->view($this->config->item('auth_register_view'),$data);