2016-10-12 22:12:25 -04:00
|
|
|
<?php declare(strict_types=1);
|
2014-04-23 15:53:16 -04:00
|
|
|
/**
|
|
|
|
* Query
|
|
|
|
*
|
2016-09-07 13:17:17 -04:00
|
|
|
* SQL Query Builder / Database Abstraction Layer
|
2014-04-23 15:53:16 -04:00
|
|
|
*
|
2020-04-10 20:54:31 -04:00
|
|
|
* PHP version 7.4
|
2016-09-07 13:17:17 -04:00
|
|
|
*
|
|
|
|
* @package Query
|
|
|
|
* @author Timothy J. Warren <tim@timshomepage.net>
|
2020-03-18 11:31:56 -04:00
|
|
|
* @copyright 2012 - 2020 Timothy J. Warren
|
2016-09-07 13:17:17 -04:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2019-12-11 16:49:42 -05:00
|
|
|
* @link https://git.timshomepage.net/aviat/Query
|
|
|
|
* @version 3.0.0
|
2014-04-23 15:53:16 -04:00
|
|
|
*/
|
2016-09-07 17:39:19 -04:00
|
|
|
namespace Query\Drivers;
|
2014-04-23 15:53:16 -04:00
|
|
|
|
|
|
|
/**
|
2018-01-24 15:03:41 -05:00
|
|
|
* Parent for database-specific syntax subclasses
|
2014-04-23 15:53:16 -04:00
|
|
|
*/
|
2015-11-10 10:12:23 -05:00
|
|
|
abstract class AbstractSQL implements SQLInterface {
|
2014-04-23 15:53:16 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Limit clause
|
|
|
|
*
|
2020-04-17 14:57:56 -04:00
|
|
|
* @param int $offset
|
2014-04-23 15:53:16 -04:00
|
|
|
*/
|
2020-04-17 14:57:56 -04:00
|
|
|
public function limit(string $sql, int $limit, ?int $offset=NULL): string
|
2014-04-23 15:53:16 -04:00
|
|
|
{
|
|
|
|
$sql .= "\nLIMIT {$limit}";
|
|
|
|
|
|
|
|
if (is_numeric($offset))
|
|
|
|
{
|
|
|
|
$sql .= " OFFSET {$offset}";
|
|
|
|
}
|
|
|
|
|
|
|
|
return $sql;
|
|
|
|
}
|
|
|
|
}
|