FaaPz / PDO

Just another PDO database library
MIT License
316 stars 103 forks source link

LimitClause: offset compatibility. Fixes #47 #49

Closed kbaryshnikov closed 7 years ago

kbaryshnikov commented 8 years ago

Use the de-facto standard LIMIT n OFFSET m syntax instead of MySQL-specific LIMIT n,m.

It won't solve the incorrect SQL issue when calling ->limit($num, $offset)->offset($offset), but this problem existed anyway. and doesn't seem to be solvable without reworking LimitClause and OffsetClause into a single LimitOffsetClause.

alaabataineh92 commented 8 years ago

The problem in statementContainer.php

public function limit($number, $offset = null) { $this->limitClause->limit($number, $offset);

    return $this;
}

Change to

public function limit($number, $offset = 0) { $this->limitClause->limit($number, $offset);

    return $this;
}
kbaryshnikov commented 8 years ago

@alaa92 How is this related to postgresql compatibility?

FaaPz commented 7 years ago

Thanks guys! I've merged @delef's PR (#62) already, which includes this fix. 😄