mirror of
https://github.com/slawkens/myaac.git
synced 2025-04-27 09:49:22 +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;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function select($table, $data)
|
public function select($table, $where, $limit = null)
|
||||||
{
|
{
|
||||||
$fields = array_keys($data);
|
$fields = array_keys($where);
|
||||||
$values = array_values($data);
|
$values = array_values($where);
|
||||||
$query = 'SELECT * FROM ' . $this->tableName($table) . ' WHERE (';
|
$query = 'SELECT * FROM ' . $this->tableName($table) . ' WHERE (';
|
||||||
|
|
||||||
$count = count($fields);
|
$count = count($fields);
|
||||||
for ($i = 0; $i < $count; $i++)
|
for ($i = 0; $i < $count; $i++)
|
||||||
$query.= $this->fieldName($fields[$i]).' = '.$this->quote($values[$i]).' AND ';
|
$query.= $this->fieldName($fields[$i]).' = '.$this->quote($values[$i]).' AND ';
|
||||||
|
|
||||||
$query = substr($query, 0, -4);
|
$query = substr($query, 0, -4);
|
||||||
$query.=');';
|
$query = substr($query, 0, -4);
|
||||||
|
if (isset($limit))
|
||||||
|
$query .=') LIMIT '.$limit.';';
|
||||||
|
else
|
||||||
|
$query .=');';
|
||||||
|
|
||||||
$query = $this->query($query);
|
$query = $this->query($query);
|
||||||
if($query->rowCount() != 1) return false;
|
if($query->rowCount() != 1) return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user