mirror of
https://github.com/dg/dibi.git
synced 2025-08-06 14:16:39 +02:00
code formatting: 4 spaces -> tabs
This commit is contained in:
@@ -29,64 +29,64 @@
|
||||
*/
|
||||
class DibiDataSource extends /*Nette::*/Object implements IDataSource
|
||||
{
|
||||
/** @var DibiConnection */
|
||||
private $connection;
|
||||
/** @var DibiConnection */
|
||||
private $connection;
|
||||
|
||||
/** @var string */
|
||||
private $sql;
|
||||
/** @var string */
|
||||
private $sql;
|
||||
|
||||
/** @var int */
|
||||
private $count;
|
||||
/** @var int */
|
||||
private $count;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param string SQL command or table name, as data source
|
||||
* @param DibiConnection connection
|
||||
*/
|
||||
public function __construct($sql, DibiConnection $connection = NULL)
|
||||
{
|
||||
if (strpos($sql, ' ') === FALSE) {
|
||||
// table name
|
||||
$this->sql = $sql;
|
||||
} else {
|
||||
// SQL command
|
||||
$this->sql = '(' . $sql . ') AS [source]';
|
||||
}
|
||||
/**
|
||||
* @param string SQL command or table name, as data source
|
||||
* @param DibiConnection connection
|
||||
*/
|
||||
public function __construct($sql, DibiConnection $connection = NULL)
|
||||
{
|
||||
if (strpos($sql, ' ') === FALSE) {
|
||||
// table name
|
||||
$this->sql = $sql;
|
||||
} else {
|
||||
// SQL command
|
||||
$this->sql = '(' . $sql . ') AS [source]';
|
||||
}
|
||||
|
||||
$this->connection = $connection === NULL ? dibi::getConnection() : $connection;
|
||||
}
|
||||
$this->connection = $connection === NULL ? dibi::getConnection() : $connection;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param int offset
|
||||
* @param int limit
|
||||
* @param array columns
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator($offset = NULL, $limit = NULL, $cols = NULL)
|
||||
{
|
||||
return $this->connection->query('
|
||||
SELECT *
|
||||
FROM', $this->sql, '
|
||||
%ofs %lmt', $offset, $limit
|
||||
);
|
||||
}
|
||||
/**
|
||||
* @param int offset
|
||||
* @param int limit
|
||||
* @param array columns
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator($offset = NULL, $limit = NULL, $cols = NULL)
|
||||
{
|
||||
return $this->connection->query('
|
||||
SELECT *
|
||||
FROM', $this->sql, '
|
||||
%ofs %lmt', $offset, $limit
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
if ($this->count === NULL) {
|
||||
$this->count = $this->connection->query('
|
||||
SELECT COUNT(*) FROM', $this->sql
|
||||
)->fetchSingle();
|
||||
}
|
||||
return $this->count;
|
||||
}
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
if ($this->count === NULL) {
|
||||
$this->count = $this->connection->query('
|
||||
SELECT COUNT(*) FROM', $this->sql
|
||||
)->fetchSingle();
|
||||
}
|
||||
return $this->count;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user