![]() |
a sql condition like this is not gonna work in CI - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: a sql condition like this is not gonna work in CI (/showthread.php?tid=16516) |
a sql condition like this is not gonna work in CI - El Forum - 03-09-2009 [eluser]runrun[/eluser] I am pretty sure that's valid, as I used the same query I gave you on this site www.badede.com , it works as expected and that site isn't using CI. The listing_photo table Code: CREATE TABLE IF NOT EXISTS `listing_photo` ( a sql condition like this is not gonna work in CI - El Forum - 03-09-2009 [eluser]TheFuzzy0ne[/eluser] The trouble is though, CI doesn't touch queries that go through $this-db->query(), so I can't see how it could possible be CI. a sql condition like this is not gonna work in CI - El Forum - 03-09-2009 [eluser]runrun[/eluser] Well you had my listing table, just try something simple like this you can see the problem. controller: Code: $data['query'] = $this->db->query("SELECT * FROM listing WHERE close_time > '".time()."'"); view: Code: <?php foreach($query->result() as $row):?> a sql condition like this is not gonna work in CI - El Forum - 03-09-2009 [eluser]drewbee[/eluser] Fuzzy, its valid syntax, just as is comparing against other tables, or comparing against constats. runrun, you are not getting any results back because the database is returning what you are selecting. Your query is currently trying to find any dates whose closing times are greater then right now (time()); Taken from your previous data dump on the last page, 1234476360 was a timestamp listed for closing time. Last I checked, 1234476360 is currently less then time() (1236619738 at time of writing this), not greater then. You've got your symbol backwards. My guess is that you have some seriously missing logic here though, and the query is more complex then what you initially are thinking. Simply put, you have no rows whos closing time is beyond right now. What are you trying to accomplish? a sql condition like this is not gonna work in CI - El Forum - 03-09-2009 [eluser]TheFuzzy0ne[/eluser] I'm baffled! Code: <?php Result: [quote author="" date=""] 1 row(s) found [/quote] a sql condition like this is not gonna work in CI - El Forum - 03-09-2009 [eluser]TheFuzzy0ne[/eluser] Drew, the problem is that all of the rows are being returned. However, my test of the same database query, both via PHPMyadmin and within CI, return a single row. a sql condition like this is not gonna work in CI - El Forum - 03-09-2009 [eluser]jdfwarrior[/eluser] The he said it was the other way around? That he only got one result, and it was supposed to return all? a sql condition like this is not gonna work in CI - El Forum - 03-09-2009 [eluser]drewbee[/eluser] I think their is some confusion here. With the given data and his supplied query, I would only expect 1 row to be returned with the use of the time() function. He is saying all the rows are being returned? I don't believe that. ![]() a sql condition like this is not gonna work in CI - El Forum - 03-09-2009 [eluser]TheFuzzy0ne[/eluser] That's what I'm trying to get to the bottom of. It doesn't make sense, and I can confirm the integrity of the data that's been posted. One thing I am sure of though, is that it's nothing to do with CodeIgniter. a sql condition like this is not gonna work in CI - El Forum - 03-09-2009 [eluser]drewbee[/eluser] I personally think he is confused. Quote:note: in the database table there is only 12 records, and all 12 records match the condition WHERE close_time > ‘“.time().”’ is a false statement. |