Implemented changes requested by Wettennet
This commit is contained in:
parent
6c53eb8cd4
commit
bb8eb0300a
|
@ -181,12 +181,10 @@ class MongoTableModel implements iDatabaseTableModel
|
||||||
// Execute the request
|
// Execute the request
|
||||||
$results = $collection->find($filter, $options);
|
$results = $collection->find($filter, $options);
|
||||||
|
|
||||||
// Return the result
|
// Convert the result into a TableModelResult
|
||||||
$return = [];
|
$result = new TableModelResult($results);
|
||||||
foreach ($results->toArray() as $result)
|
|
||||||
$return[] = iterator_to_array($result);
|
|
||||||
|
|
||||||
return $return;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -175,12 +175,13 @@ class PDOTableModel implements iDatabaseTableModel
|
||||||
{
|
{
|
||||||
// Determine which fields to select. If none provided, select all
|
// Determine which fields to select. If none provided, select all
|
||||||
$fields = (isset($options['fields']) && is_array($options['fields']) ? implode(',', $options['fields']) : '*');
|
$fields = (isset($options['fields']) && is_array($options['fields']) ? implode(',', $options['fields']) : '*');
|
||||||
|
$limit = isset($options['limit']) ? 'LIMIT ' . intval($options['limit']) : '';
|
||||||
|
|
||||||
// Apply the filter. If none provided, don't condition it
|
// Apply the filter. If none provided, don't condition it
|
||||||
$where = $this->filter($filter);
|
$where = $this->filter($filter);
|
||||||
|
|
||||||
// Generate the sql and create a PDOStatement
|
// Generate the sql and create a PDOStatement
|
||||||
$sql = "SELECT " . $fields . " FROM {$this->tableName} " . $where;
|
$sql = "SELECT " . $fields . " FROM {$this->tableName} " . $where . " " . $limit;
|
||||||
|
|
||||||
/** @var PDOStatement $statement */
|
/** @var PDOStatement $statement */
|
||||||
$this->lastStatement = $this->dbEngine->prepare($sql);
|
$this->lastStatement = $this->dbEngine->prepare($sql);
|
||||||
|
@ -235,9 +236,10 @@ class PDOTableModel implements iDatabaseTableModel
|
||||||
{
|
{
|
||||||
// Apply the filter
|
// Apply the filter
|
||||||
$where = $this->filter($filter);
|
$where = $this->filter($filter);
|
||||||
|
$limit = isset($options['limit']) ? 'LIMIT ' . intval($options['limit']) : '';
|
||||||
|
|
||||||
// Generate the sql and create a PDOStatement
|
// Generate the sql and create a PDOStatement
|
||||||
$sql = "DELETE FROM {$this->tableName} " . $where;
|
$sql = "DELETE FROM {$this->tableName} " . $where . " " . $limit;
|
||||||
|
|
||||||
/** @var PDOStatement $statement */
|
/** @var PDOStatement $statement */
|
||||||
$this->lastStatement = $this->dbEngine->prepare($sql);
|
$this->lastStatement = $this->dbEngine->prepare($sql);
|
||||||
|
|
Loading…
Reference in New Issue