Query/src/Drivers/AbstractSQL.php

45 lines
888 B
PHP
Raw Normal View History

2016-10-12 22:12:25 -04:00
<?php declare(strict_types=1);
/**
* Query
*
2016-09-07 13:17:17 -04:00
* SQL Query Builder / Database Abstraction Layer
*
2018-01-19 13:43:19 -05:00
* PHP version 7.1
2016-09-07 13:17:17 -04:00
*
* @package Query
* @author Timothy J. Warren <tim@timshomepage.net>
2018-01-19 13:43:19 -05:00
* @copyright 2012 - 2018 Timothy J. Warren
2016-09-07 13:17:17 -04:00
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @link https://git.timshomepage.net/aviat4ion/Query
*/
2016-09-07 17:39:19 -04:00
namespace Query\Drivers;
/**
* parent for database manipulation subclasses
*
* @package Query
* @subpackage Drivers
*/
2015-11-10 10:12:23 -05:00
abstract class AbstractSQL implements SQLInterface {
/**
* Limit clause
*
* @param string $sql
* @param int $limit
* @param int|bool $offset
* @return string
*/
2018-01-24 13:14:03 -05:00
public function limit(string $sql, int $limit, $offset=FALSE): string
{
$sql .= "\nLIMIT {$limit}";
if (is_numeric($offset))
{
$sql .= " OFFSET {$offset}";
}
return $sql;
}
}