Welcome Guest, Not a member yet? Register   Sign In
Active record WHERE clause not working?
#21

[eluser]xarazar[/eluser]
MySQL 5.0.9
#22

[eluser]InsiteFX[/eluser]
This is very strange, because I ran the same versions before I upgraded and my blog worked.

Maybe you have a corrupted installation, try re-installing CodeIgniter. I have had this happen several times downloading from the CodeIgniter web site, sometimes I had to download it 2 or 3 times before it would work.

But it never gave me any errors.

Just a thought.

InsiteFX
#23

[eluser]xarazar[/eluser]
I'm not getting any errors. The where() clause is simply not being assembled into a query when I put it in a separate line.
Will reinstall the core though. I'm desperate at this point...
#24

[eluser]xarazar[/eluser]
Reinstalled CI. No change. As long as I keep where() in a single line with get or use get_where() everything is OK. When the where() clause is in its individual line the system seems to disregard it.
#25

[eluser]xarazar[/eluser]
OK. Just tested Active Records with more functions and this query:

Code:
$q = $this->db->where('parent', 0)->where('visible', 1)->order_by('position', 'desc')->get('content');

works fine whereas this one:

Code:
$this->db->where('parent', 0);
$this->db->where('visible', 1);
$this->db->order_by('position', 'desc');
$q = $this->db->get('content');

fails miserably and returns the entire content of the 'content' table ordered by default.

So it's clear that there problem doesn't lie in the where() clause but in assembling the database query.

Anybody up for a challenge?
#26

[eluser]xarazar[/eluser]
I looked closer into the DB_active_rec.php and analysed the order_by() method.
When I print_r the value of the $this->ar_orderby property it is clear that the property has the expected value of Array ( [0] => `position` desc ).

But in the _compile_select() method $this->ar_orderby is empty.

Does it mean the properties don't retain their value throughout the class?

Thanks in advance for any contribution.
#27

[eluser]helmutbjorg[/eluser]
[quote author="noctrum" date="1299692814"]Do you have a constructor in the model you just haven't posted? Are you calling parent::__construct(); in all of your controller and model constructors (if they exist)?[/quote]

This is a good point. Have you checked this?
#28

[eluser]xarazar[/eluser]
I do have a constructor in my controller but not in the model. But it doesn't seem to make any difference...
#29

[eluser]xarazar[/eluser]
I thought I'd update this thread in case somebody stumbled upon this issue.
Although I don't know what specifically caused the error after some further testing it became apparent that a setting in php.ini was the reason. I say "a setting" because server administrators were far from being helpful and all they did was to swap php.ini from another server where CI 2.0 worked with no problems.
I guess it would be possible to go through both php.ini files to find discrepancies but I quickly gave up on this idea and just accepted the solution.

If somebody has a suggestion to help future generations in fighting this issue please do share Smile




Theme © iAndrew 2016 - Forum software by © MyBB