Source of file AbstractSQL.php

Size: 0,847 Bytes - Last Modified: 2015-11-10T10:03:56-05:00

../src/Query/AbstractSQL.php

123456789101112131415161718192021222324252627282930313233343536
Covered by 34 test(s):
  • PgSQLQBTest::testQueryExplain
  • PgSQLQBTest::testGetLimit
  • PgSQLQBTest::testGetLimitSkip
  • PgSQLQBTest::testGetWhere
  • PgSQLQBTest::testSelectWhereGet
  • PgSQLQBTest::testSelectGet
  • PgSQLQBTest::testSelectFromLimitGet
  • PgSQLQBTest::testSelectWhereGet2
  • PgSQLQBTest::testGroup
  • PgSQLQBTest::testOrGroup
  • PgSQLQBTest::testOrNotGroup
  • PgSQLQBTest::testGroupCamelCase
  • PgSQLQBTest::testOrderBy
  • PgSQLQBTest::testOrderByRandom
  • PgSQLQBTest::testGroupBy
  • PgSQLQBTest::testOrWhere
  • PgSQLQBTest::testCountAllResults2
  • SQLiteQBTest::testQueryExplain
  • SQLiteQBTest::testGetLimit
  • SQLiteQBTest::testGetLimitSkip
  • SQLiteQBTest::testGetWhere
  • SQLiteQBTest::testSelectWhereGet
  • SQLiteQBTest::testSelectGet
  • SQLiteQBTest::testSelectFromLimitGet
  • SQLiteQBTest::testSelectWhereGet2
  • SQLiteQBTest::testGroup
  • SQLiteQBTest::testOrGroup
  • SQLiteQBTest::testOrNotGroup
  • SQLiteQBTest::testGroupCamelCase
  • SQLiteQBTest::testOrderBy
  • SQLiteQBTest::testOrderByRandom
  • SQLiteQBTest::testGroupBy
  • SQLiteQBTest::testOrWhere
  • SQLiteQBTest::testCountAllResults2
3738
Covered by 34 test(s):
  • PgSQLQBTest::testQueryExplain
  • PgSQLQBTest::testGetLimit
  • PgSQLQBTest::testGetLimitSkip
  • PgSQLQBTest::testGetWhere
  • PgSQLQBTest::testSelectWhereGet
  • PgSQLQBTest::testSelectGet
  • PgSQLQBTest::testSelectFromLimitGet
  • PgSQLQBTest::testSelectWhereGet2
  • PgSQLQBTest::testGroup
  • PgSQLQBTest::testOrGroup
  • PgSQLQBTest::testOrNotGroup
  • PgSQLQBTest::testGroupCamelCase
  • PgSQLQBTest::testOrderBy
  • PgSQLQBTest::testOrderByRandom
  • PgSQLQBTest::testGroupBy
  • PgSQLQBTest::testOrWhere
  • PgSQLQBTest::testCountAllResults2
  • SQLiteQBTest::testQueryExplain
  • SQLiteQBTest::testGetLimit
  • SQLiteQBTest::testGetLimitSkip
  • SQLiteQBTest::testGetWhere
  • SQLiteQBTest::testSelectWhereGet
  • SQLiteQBTest::testSelectGet
  • SQLiteQBTest::testSelectFromLimitGet
  • SQLiteQBTest::testSelectWhereGet2
  • SQLiteQBTest::testGroup
  • SQLiteQBTest::testOrGroup
  • SQLiteQBTest::testOrNotGroup
  • SQLiteQBTest::testGroupCamelCase
  • SQLiteQBTest::testOrderBy
  • SQLiteQBTest::testOrderByRandom
  • SQLiteQBTest::testGroupBy
  • SQLiteQBTest::testOrWhere
  • SQLiteQBTest::testCountAllResults2
39
Covered by 34 test(s):
  • PgSQLQBTest::testQueryExplain
  • PgSQLQBTest::testGetLimit
  • PgSQLQBTest::testGetLimitSkip
  • PgSQLQBTest::testGetWhere
  • PgSQLQBTest::testSelectWhereGet
  • PgSQLQBTest::testSelectGet
  • PgSQLQBTest::testSelectFromLimitGet
  • PgSQLQBTest::testSelectWhereGet2
  • PgSQLQBTest::testGroup
  • PgSQLQBTest::testOrGroup
  • PgSQLQBTest::testOrNotGroup
  • PgSQLQBTest::testGroupCamelCase
  • PgSQLQBTest::testOrderBy
  • PgSQLQBTest::testOrderByRandom
  • PgSQLQBTest::testGroupBy
  • PgSQLQBTest::testOrWhere
  • PgSQLQBTest::testCountAllResults2
  • SQLiteQBTest::testQueryExplain
  • SQLiteQBTest::testGetLimit
  • SQLiteQBTest::testGetLimitSkip
  • SQLiteQBTest::testGetWhere
  • SQLiteQBTest::testSelectWhereGet
  • SQLiteQBTest::testSelectGet
  • SQLiteQBTest::testSelectFromLimitGet
  • SQLiteQBTest::testSelectWhereGet2
  • SQLiteQBTest::testGroup
  • SQLiteQBTest::testOrGroup
  • SQLiteQBTest::testOrNotGroup
  • SQLiteQBTest::testGroupCamelCase
  • SQLiteQBTest::testOrderBy
  • SQLiteQBTest::testOrderByRandom
  • SQLiteQBTest::testGroupBy
  • SQLiteQBTest::testOrWhere
  • SQLiteQBTest::testCountAllResults2
40
Covered by 30 test(s):
  • PgSQLQBTest::testQueryExplain
  • PgSQLQBTest::testGetLimitSkip
  • PgSQLQBTest::testGetWhere
  • PgSQLQBTest::testSelectWhereGet
  • PgSQLQBTest::testSelectGet
  • PgSQLQBTest::testSelectWhereGet2
  • PgSQLQBTest::testGroup
  • PgSQLQBTest::testOrGroup
  • PgSQLQBTest::testOrNotGroup
  • PgSQLQBTest::testGroupCamelCase
  • PgSQLQBTest::testOrderBy
  • PgSQLQBTest::testOrderByRandom
  • PgSQLQBTest::testGroupBy
  • PgSQLQBTest::testOrWhere
  • PgSQLQBTest::testCountAllResults2
  • SQLiteQBTest::testQueryExplain
  • SQLiteQBTest::testGetLimitSkip
  • SQLiteQBTest::testGetWhere
  • SQLiteQBTest::testSelectWhereGet
  • SQLiteQBTest::testSelectGet
  • SQLiteQBTest::testSelectWhereGet2
  • SQLiteQBTest::testGroup
  • SQLiteQBTest::testOrGroup
  • SQLiteQBTest::testOrNotGroup
  • SQLiteQBTest::testGroupCamelCase
  • SQLiteQBTest::testOrderBy
  • SQLiteQBTest::testOrderByRandom
  • SQLiteQBTest::testGroupBy
  • SQLiteQBTest::testOrWhere
  • SQLiteQBTest::testCountAllResults2
41
Covered by 30 test(s):
  • PgSQLQBTest::testQueryExplain
  • PgSQLQBTest::testGetLimitSkip
  • PgSQLQBTest::testGetWhere
  • PgSQLQBTest::testSelectWhereGet
  • PgSQLQBTest::testSelectGet
  • PgSQLQBTest::testSelectWhereGet2
  • PgSQLQBTest::testGroup
  • PgSQLQBTest::testOrGroup
  • PgSQLQBTest::testOrNotGroup
  • PgSQLQBTest::testGroupCamelCase
  • PgSQLQBTest::testOrderBy
  • PgSQLQBTest::testOrderByRandom
  • PgSQLQBTest::testGroupBy
  • PgSQLQBTest::testOrWhere
  • PgSQLQBTest::testCountAllResults2
  • SQLiteQBTest::testQueryExplain
  • SQLiteQBTest::testGetLimitSkip
  • SQLiteQBTest::testGetWhere
  • SQLiteQBTest::testSelectWhereGet
  • SQLiteQBTest::testSelectGet
  • SQLiteQBTest::testSelectWhereGet2
  • SQLiteQBTest::testGroup
  • SQLiteQBTest::testOrGroup
  • SQLiteQBTest::testOrNotGroup
  • SQLiteQBTest::testGroupCamelCase
  • SQLiteQBTest::testOrderBy
  • SQLiteQBTest::testOrderByRandom
  • SQLiteQBTest::testGroupBy
  • SQLiteQBTest::testOrWhere
  • SQLiteQBTest::testCountAllResults2
4243
Covered by 34 test(s):
  • PgSQLQBTest::testQueryExplain
  • PgSQLQBTest::testGetLimit
  • PgSQLQBTest::testGetLimitSkip
  • PgSQLQBTest::testGetWhere
  • PgSQLQBTest::testSelectWhereGet
  • PgSQLQBTest::testSelectGet
  • PgSQLQBTest::testSelectFromLimitGet
  • PgSQLQBTest::testSelectWhereGet2
  • PgSQLQBTest::testGroup
  • PgSQLQBTest::testOrGroup
  • PgSQLQBTest::testOrNotGroup
  • PgSQLQBTest::testGroupCamelCase
  • PgSQLQBTest::testOrderBy
  • PgSQLQBTest::testOrderByRandom
  • PgSQLQBTest::testGroupBy
  • PgSQLQBTest::testOrWhere
  • PgSQLQBTest::testCountAllResults2
  • SQLiteQBTest::testQueryExplain
  • SQLiteQBTest::testGetLimit
  • SQLiteQBTest::testGetLimitSkip
  • SQLiteQBTest::testGetWhere
  • SQLiteQBTest::testSelectWhereGet
  • SQLiteQBTest::testSelectGet
  • SQLiteQBTest::testSelectFromLimitGet
  • SQLiteQBTest::testSelectWhereGet2
  • SQLiteQBTest::testGroup
  • SQLiteQBTest::testOrGroup
  • SQLiteQBTest::testOrNotGroup
  • SQLiteQBTest::testGroupCamelCase
  • SQLiteQBTest::testOrderBy
  • SQLiteQBTest::testOrderByRandom
  • SQLiteQBTest::testGroupBy
  • SQLiteQBTest::testOrWhere
  • SQLiteQBTest::testCountAllResults2
44454647
<?php
/**
 * Query
 *
 * Free Query Builder / Database Abstraction Layer
 *
 * @author		Timothy J. Warren
 * @copyright	Copyright (c) 2012 - 2014
 * @link 		https://github.com/aviat4ion/Query
 * @license		http://philsturgeon.co.uk/code/dbad-license
 * @package		Query
 */

// --------------------------------------------------------------------------

namespace Query;

/**
 * parent for database manipulation subclasses
 *
 * @package Query
 * @subpackage Drivers
 */
abstract class AbstractSQL implements SQLInterface {

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

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

		return $sql;
	}
}
// End of abstract_sql.php