Welcome Guest, Not a member yet? Register   Sign In
mysql queries seem stuck
#1

[eluser]domainsvault[/eluser]
Well, I am using pretty straight forward answers from the guide as I build this project I am working on. However I seem to have run into a snag with mysql. The queries are good, the run as expected however they seem to be getting caught. If I trigger the same sql query I get the same data again and again. But let me emphise on that a bit. Its a comment like system. People post a comment, when the come back or jump around to various pages the comments should theoretically show new comments if any where posted new in the mean time. So theres no comments in the system but the displayed data stays the same no matter what.

I guess with that, is there some type of cache invoked by CI automatically? if so is there a way to by pass that catch within any given function but have it remain working otherwise?
#2

[eluser]duellsy[/eluser]
would probably be worth posting the code and queries that you are using... otherwise there's not much anybody can do to help out here.

there is caching, but it's not on by default, so gut feel is that there's something bogus with your queries
#3

[eluser]domainsvault[/eluser]
Ill spare for the most part the entirety as its not particularly important to the query itself in question.

Code:
$currentUserFromGroup = $row->user_id;
$sql = "SELECT * FROM cm_idea WHERE user_id = ? ORDER by created DESC LIMIT 5";
$ideaQuery = $this->db->query($sql, array($currentUserFromGroup));
foreach($ideaQuery->result() as $rowX){
/*code that builds an array to sort from based on users grouped within certain groups sorts the array for chronological order then json encodes it for output as its an ajax driven element. I am working on*/
}

That said, the query works I get my results, however if I reload the page, or even sign out then back in as a different user whose comments should be different based on the users they have in there list (also mind you, the comments do pull differently after a little while if i sign out and back in) so for all intensive purposes the code does what its supposed to do.. It just seems its caught in some type of cache somewhere. CI being fairly new to me I am curious all around as to how this happens.

Mind you with this I am also coming in on a project about 2 months into build time do not know the full scope of everything that is the system they developed as of yet, and chances are its going to be completely rebuilt by me in upcoming months, just right now I have to work with what I was given.. that said it is plausible that someone did flip the metaphorical switch on that cache concept, which that be the case brings me back to is there a way to bypass said caching with just what I am working on so I don't effect things that may require the caching thats already been developed?

Or i could be wrong and you right, where my query is messed up somewhere. But as I said generally speaking the query works, pulls the right data out sorts it right and does everything as expected, only thing thats happening is if i refresh the page go to a different page where I have plugged in a similar feature. The query generally leaves the same result time and time again even with new comments in the system added since the initial query was given
#4

[eluser]duellsy[/eluser]
strange.
before your foreach add this:

Code:
echo $this->db->last_query();

just to make sure the query is actually unique for each user

Alternatively, I would do it this way:

Code:
$this->db->where('user_id', $currentUserFromGroup);
$this->db->orderby('created DESC');
$this->db->limit(5);
$query = $this->db->get('cm_idea');

$ideas = $query->result();

foreach($ideas as $idea){
/*code that builds an array to sort from based on users grouped within certain groups sorts the array for chronological order then json encodes it for output as its an ajax driven element. I am working on*/
}




Theme © iAndrew 2016 - Forum software by © MyBB