mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-26 17:29:21 +02:00
Add $limit parameter to $db->select method
This commit is contained in:
parent
7469d520c9
commit
1c6b241239
@ -91,17 +91,22 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB
|
||||
return $ret;
|
||||
}
|
||||
|
||||
public function select($table, $data)
|
||||
public function select($table, $where, $limit = null)
|
||||
{
|
||||
$fields = array_keys($data);
|
||||
$values = array_values($data);
|
||||
$fields = array_keys($where);
|
||||
$values = array_values($where);
|
||||
$query = 'SELECT * FROM ' . $this->tableName($table) . ' WHERE (';
|
||||
|
||||
$count = count($fields);
|
||||
for ($i = 0; $i < $count; $i++)
|
||||
$query.= $this->fieldName($fields[$i]).' = '.$this->quote($values[$i]).' AND ';
|
||||
|
||||
$query = substr($query, 0, -4);
|
||||
$query.=');';
|
||||
$query = substr($query, 0, -4);
|
||||
if (isset($limit))
|
||||
$query .=') LIMIT '.$limit.';';
|
||||
else
|
||||
$query .=');';
|
||||
|
||||
$query = $this->query($query);
|
||||
if($query->rowCount() != 1) return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user