Source of file AbstractSQL.php

Size: 0,847 Bytes - Last Modified: 2018-01-25T14:51:55+00:00

src/Drivers/AbstractSQL.php

1234567891011121314151617181920212223242526272829303132
Covered by 38 test(s):
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testQueryExplain
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGetLimit
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGetLimitSkip
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGetWhere
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectWhereGet
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectGet
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectFromLimitGet
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectWhereGet2
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGroup
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrGroup
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrNotGroup
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testAndNotGroupStart
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testNotGroupStart
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGroupCamelCase
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrderBy
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrderByRandom
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGroupBy
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrWhere
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testCountAllResults2
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testQueryExplain
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGetLimit
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGetLimitSkip
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGetWhere
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectWhereGet
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectGet
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectFromLimitGet
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectWhereGet2
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGroup
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrGroup
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrNotGroup
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testAndNotGroupStart
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testNotGroupStart
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGroupCamelCase
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrderBy
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrderByRandom
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGroupBy
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrWhere
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testCountAllResults2
3334
Covered by 38 test(s):
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testQueryExplain
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGetLimit
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGetLimitSkip
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGetWhere
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectWhereGet
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectGet
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectFromLimitGet
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectWhereGet2
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGroup
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrGroup
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrNotGroup
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testAndNotGroupStart
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testNotGroupStart
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGroupCamelCase
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrderBy
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrderByRandom
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGroupBy
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrWhere
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testCountAllResults2
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testQueryExplain
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGetLimit
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGetLimitSkip
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGetWhere
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectWhereGet
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectGet
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectFromLimitGet
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectWhereGet2
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGroup
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrGroup
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrNotGroup
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testAndNotGroupStart
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testNotGroupStart
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGroupCamelCase
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrderBy
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrderByRandom
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGroupBy
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrWhere
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testCountAllResults2
3536
Covered by 34 test(s):
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testQueryExplain
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGetLimitSkip
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGetWhere
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectWhereGet
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectGet
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectWhereGet2
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGroup
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrGroup
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrNotGroup
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testAndNotGroupStart
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testNotGroupStart
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGroupCamelCase
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrderBy
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrderByRandom
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGroupBy
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrWhere
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testCountAllResults2
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testQueryExplain
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGetLimitSkip
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGetWhere
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectWhereGet
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectGet
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectWhereGet2
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGroup
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrGroup
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrNotGroup
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testAndNotGroupStart
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testNotGroupStart
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGroupCamelCase
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrderBy
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrderByRandom
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGroupBy
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrWhere
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testCountAllResults2
373839
Covered by 38 test(s):
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testQueryExplain
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGetLimit
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGetLimitSkip
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGetWhere
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectWhereGet
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectGet
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectFromLimitGet
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testSelectWhereGet2
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGroup
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrGroup
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrNotGroup
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testAndNotGroupStart
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testNotGroupStart
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGroupCamelCase
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrderBy
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrderByRandom
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testGroupBy
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testOrWhere
  • Query\Tests\Drivers\PgSQL\PgSQLQueryBuilderTest::testCountAllResults2
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testQueryExplain
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGetLimit
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGetLimitSkip
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGetWhere
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectWhereGet
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectGet
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectFromLimitGet
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testSelectWhereGet2
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGroup
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrGroup
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrNotGroup
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testAndNotGroupStart
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testNotGroupStart
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGroupCamelCase
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrderBy
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrderByRandom
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testGroupBy
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testOrWhere
  • Query\Tests\Drivers\SQLite\SQLiteQueryBuilderTest::testCountAllResults2
404142
<?php declare(strict_types=1);
/**
 * Query
 *
 * SQL Query Builder / Database Abstraction Layer
 *
 * PHP version 7.1
 *
 * @package     Query
 * @author      Timothy J. Warren <tim@timshomepage.net>
 * @copyright   2012 - 2018 Timothy J. Warren
 * @license     http://www.opensource.org/licenses/mit-license.html  MIT License
 * @link        https://git.timshomepage.net/aviat4ion/Query
 */
namespace Query\Drivers;

/**
 * Parent for database-specific syntax subclasses
 */
abstract class AbstractSQL implements SQLInterface {

	/**
	 * Limit clause
	 *
	 * @param string $sql
	 * @param int $limit
	 * @param int|bool $offset
	 * @return string
	 */
	public function limit(string $sql, int $limit, $offset=FALSE): string
	{
		$sql .= "\nLIMIT {$limit}";

		if (is_numeric($offset))
		{
			$sql .= " OFFSET {$offset}";
		}

		return $sql;
	}
}