Welcome Guest, Not a member yet? Register   Sign In
Active Record and SQL error
#11

[eluser]richie123[/eluser]
@nzmike: no, it different! $offset = 0 mean I query from the begining of a rows set

for example:
select * from user limit 0, 1 -> get 1st row
select * from user limit 1, 1 -> get 2nd row ...

I try this

Code:
if($offset!='')
   $this->db->limit(1, $offset);            
$query = $this->db->get('user');

but get the same result Sad
#12

[eluser]Aken[/eluser]
This is not a bug. The limit() functions checks for an empty string using this line:

Code:
if ($offset != '')

An integer of 0 will be the same as an empty string in that context. So that is why your offset of 0 is not being displayed.

nzmike is right, though... A query with only a limit set (with no offset) will always return results from the beginning of the row set (up to the limit). There's no reason you should need to make sure the offset of 0 is included, because it's already there by default. Remember that the offset does not mean "Start at 10th id" or similar, it means "Start at the 10th row of the matching rows".
#13

[eluser]nzmike[/eluser]
If you wanted to get the first row you could either use

Code:
SELECT * FROM user limit 0, 1

or

Code:
SELECT * FROM user limit 1

These statements do exactly the same thing.

What is it you're trying to do?
#14

[eluser]richie123[/eluser]
@Aken, nzmike: thanks you, I got it! sometime i'm so silly ^^




Theme © iAndrew 2016 - Forum software by © MyBB