Add Or Not Like method
This commit is contained in:
parent
ca601623ba
commit
3eb4d889f9
@ -114,9 +114,7 @@ class RoboFile extends \Robo\Tasks {
|
||||
public function docs()
|
||||
{
|
||||
$cmd_parts = [
|
||||
'cd build',
|
||||
'../vendor/bin/phpdox',
|
||||
'cd ..'
|
||||
'phpdoc'
|
||||
];
|
||||
$this->_run($cmd_parts, ' && ');
|
||||
}
|
||||
@ -232,6 +230,7 @@ class RoboFile extends \Robo\Tasks {
|
||||
->configFile('phpunit.xml')
|
||||
->printed(true)
|
||||
->run();
|
||||
$this->_run(["php tests/index.php"]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,7 @@
|
||||
"role": "Developer"
|
||||
}],
|
||||
"require": {
|
||||
"php": ">=5.4"
|
||||
"php": "^7.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"consolidation/robo": "1.0.0-RC2",
|
||||
@ -33,18 +33,14 @@
|
||||
"phpmd/phpmd": "^2.4",
|
||||
"phpunit/phpunit": "^5.5",
|
||||
"sebastian/phpcpd": "^2.0",
|
||||
"simpletest/simpletest": "^1.1",
|
||||
"squizlabs/php_codesniffer": "^3.0.0@RC",
|
||||
"theseer/phpdox": "^0.9.0"
|
||||
"phpdocumentor/phpdocumentor": "2.*"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Query\\": "src/Query"
|
||||
},
|
||||
"files": ["src/common.php"]
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4" : {
|
||||
"CodeIgniter\\": "build/CodeIgniter"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
bootstrap="tests/bootstrap.php">
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory suffix=".php">src</directory>
|
||||
<directory suffix=".php">src/</directory>
|
||||
<file>autoload.php</file>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
@ -13,18 +13,17 @@
|
||||
* @link https://git.timshomepage.net/aviat4ion/Query
|
||||
*/
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace Query;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Generic exception for bad drivers
|
||||
*
|
||||
* @package Query
|
||||
* @subpackage Core
|
||||
*/
|
||||
class BadDBDriverException extends \InvalidArgumentException {
|
||||
class BadDBDriverException extends InvalidArgumentException {
|
||||
}
|
||||
|
||||
// End of BadDBDriverException.php
|
@ -13,11 +13,11 @@
|
||||
* @link https://git.timshomepage.net/aviat4ion/Query
|
||||
*/
|
||||
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
namespace Query;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use DomainException;
|
||||
|
||||
/**
|
||||
* Connection manager class to manage connections for the
|
||||
* Query method
|
||||
@ -54,12 +54,12 @@ final class ConnectionManager {
|
||||
/**
|
||||
* Private clone method to prevent cloning
|
||||
*
|
||||
* @throws \DomainException
|
||||
* @throws DomainException
|
||||
* @return void
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
throw new \DomainException("Can't clone singleton");
|
||||
throw new DomainException("Can't clone singleton");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@ -67,12 +67,12 @@ final class ConnectionManager {
|
||||
/**
|
||||
* Prevent serialization of this object
|
||||
*
|
||||
* @throws \DomainException
|
||||
* @throws DomainException
|
||||
* @return void
|
||||
*/
|
||||
public function __sleep()
|
||||
{
|
||||
throw new \DomainException("No serializing of singleton");
|
||||
throw new DomainException("No serializing of singleton");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@ -80,12 +80,12 @@ final class ConnectionManager {
|
||||
/**
|
||||
* Make sure serialize/deserialize doesn't work
|
||||
*
|
||||
* @throws \DomainException
|
||||
* @throws DomainException
|
||||
* @return void
|
||||
*/
|
||||
public function __wakeup()
|
||||
{
|
||||
throw new \DomainException("Can't unserialize singleton");
|
||||
throw new DomainException("Can't unserialize singleton");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@ -113,7 +113,7 @@ final class ConnectionManager {
|
||||
*
|
||||
* @param string|array|object $name
|
||||
* @return QueryBuilder
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function get_connection($name = '')
|
||||
{
|
||||
@ -128,7 +128,7 @@ final class ConnectionManager {
|
||||
}
|
||||
|
||||
// You should actually connect before trying to get a connection...
|
||||
throw new \InvalidArgumentException("The specified connection does not exist");
|
||||
throw new InvalidArgumentException("The specified connection does not exist");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
@ -79,7 +79,7 @@ class Driver extends AbstractDriver {
|
||||
* @param string $user
|
||||
* @param string $pass
|
||||
* @param array $options
|
||||
* @throws \PDOException
|
||||
* @throws PDOException
|
||||
*/
|
||||
public function __construct($dbpath, $user='SYSDBA', $pass='masterkey', array $options = [])
|
||||
{
|
||||
|
@ -26,7 +26,7 @@ interface PDOStatementInterface {
|
||||
* Bind a column to a PHP variable
|
||||
*
|
||||
* @param mixed $column Number or name of the column in the result set
|
||||
* @param mixed &$param Name of the PHP variable to which the column will be bound
|
||||
* @param mixed $param Name of the PHP variable to which the column will be bound
|
||||
* @param int $type Data type of the parameter, specified by the PDO::PARAM_* constants
|
||||
* @param int $maxlen A hint for pre-allocation
|
||||
* @param mixed $driverdata Optional parameter(s) for the driver
|
||||
@ -40,7 +40,7 @@ interface PDOStatementInterface {
|
||||
* @param mixed $parameter Parameter identifier. For a prepared statement using named placeholders, this will be a
|
||||
* parameter name of the form :name. For a prepared statement using question mark placeholders, this will be the
|
||||
* 1-indexed position of the parameter.
|
||||
* @param mixed &$variable Name of the PHP variable to bind to the SQL statement parameter.
|
||||
* @param mixed $variable Name of the PHP variable to bind to the SQL statement parameter.
|
||||
* @param int $data_type Explicit data type for the parameter using the PDO::PARAM_* constants. To return an INOUT
|
||||
* parameter from a stored procedure, use the bitwise OR operator to set the PDO::PARAM_INPUT_OUTPUT bits
|
||||
* for the data_type parameter.
|
||||
|
@ -16,6 +16,7 @@
|
||||
namespace Query;
|
||||
|
||||
use Query\Drivers\DriverInterface;
|
||||
use BadMethodCallException;
|
||||
|
||||
/**
|
||||
* Convenience class for creating sql queries - also the class that
|
||||
@ -99,7 +100,7 @@ class QueryBuilder extends AbstractQueryBuilder implements QueryBuilderInterface
|
||||
* @param string $name
|
||||
* @param array $params
|
||||
* @return mixed
|
||||
* @throws \BadMethodCallException
|
||||
* @throws BadMethodCallException
|
||||
*/
|
||||
public function __call($name, $params)
|
||||
{
|
||||
@ -118,7 +119,7 @@ class QueryBuilder extends AbstractQueryBuilder implements QueryBuilderInterface
|
||||
|
||||
}
|
||||
|
||||
throw new \BadMethodCallException("Method does not exist");
|
||||
throw new BadMethodCallException("Method does not exist");
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
@ -174,7 +175,7 @@ class QueryBuilder extends AbstractQueryBuilder implements QueryBuilderInterface
|
||||
* Selects the maximum value of a field from a query
|
||||
*
|
||||
* @param string $field
|
||||
* @param string|FALSE $as
|
||||
* @param string|bool $as
|
||||
* @return QueryBuilderInterface
|
||||
*/
|
||||
public function select_max($field, $as=FALSE)
|
||||
@ -627,7 +628,9 @@ class QueryBuilder extends AbstractQueryBuilder implements QueryBuilderInterface
|
||||
*/
|
||||
public function not_group_start()
|
||||
{
|
||||
$this->_append_map('', ' NOT (', 'group_start');
|
||||
$conj = (empty($this->query_map)) ? ' WHERE ' : ' AND ';
|
||||
|
||||
$this->_append_map($conj, ' NOT (', 'group_start');
|
||||
|
||||
return $this;
|
||||
}
|
||||
@ -729,7 +732,7 @@ class QueryBuilder extends AbstractQueryBuilder implements QueryBuilderInterface
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Retreive the number of rows in the selected table
|
||||
* Retrieve the number of rows in the selected table
|
||||
*
|
||||
* @param string $table
|
||||
* @return int
|
||||
|
@ -13,7 +13,6 @@
|
||||
* @link https://git.timshomepage.net/aviat4ion/Query
|
||||
*/
|
||||
|
||||
|
||||
use Query\ConnectionManager;
|
||||
|
||||
require __DIR__ . '/../vendor/autoload.php';
|
||||
|
@ -333,6 +333,40 @@ abstract class QBTest extends Query_TestCase {
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testAndNotGroupStart()
|
||||
{
|
||||
$query = self::$db->select('id, key as k, val')
|
||||
->from('test')
|
||||
->group_start()
|
||||
->where('id >', 1)
|
||||
->where('id <', 900)
|
||||
->group_end()
|
||||
->not_group_start()
|
||||
->where('id =', 0)
|
||||
->group_end()
|
||||
->limit(2, 1)
|
||||
->get();
|
||||
|
||||
$this->assertIsA($query, 'PDOStatement');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testNotGroupStart()
|
||||
{
|
||||
$query = self::$db->select('id, key as k, val')
|
||||
->from('test')
|
||||
->not_group_start()
|
||||
->where('id =', 0)
|
||||
->group_end()
|
||||
->limit(2, 1)
|
||||
->get();
|
||||
|
||||
$this->assertIsA($query, 'PDOStatement');
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
public function testGroupCamelCase()
|
||||
{
|
||||
$query = self::$db->select('id, key as k, val')
|
||||
|
@ -13,7 +13,8 @@ class Connection_Manager_Test extends Query_TestCase {
|
||||
|
||||
public function testNoClone()
|
||||
{
|
||||
$this->setExpectedException('DomainException', "Can't clone singleton");
|
||||
$this->expectException('DomainException');
|
||||
$this->expectExceptionMessage("Can't clone singleton");
|
||||
$clone = clone self::$instance;
|
||||
}
|
||||
|
||||
|
@ -28,11 +28,29 @@ if ( ! defined('IS_QUERCUS'))
|
||||
}
|
||||
}
|
||||
|
||||
function get_json_config()
|
||||
{
|
||||
$files = array(
|
||||
__DIR__ . '/settings.json',
|
||||
__DIR__ . '/settings.json.dist'
|
||||
);
|
||||
|
||||
foreach($files as $file)
|
||||
{
|
||||
if (is_file($file))
|
||||
{
|
||||
return json_decode(file_get_contents($file));
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------------
|
||||
|
||||
// Include simpletest
|
||||
// it has to be in the tests folder
|
||||
require_once('simpletest/autorun.php');
|
||||
// Set up autoloaders
|
||||
require_once(__DIR__ . '/../vendor/autoload.php');
|
||||
require_once(__DIR__ . '/../vendor/simpletest/simpletest/autorun.php');
|
||||
|
||||
/**
|
||||
* Base class for TestCases
|
||||
@ -95,6 +113,16 @@ abstract class Query_TestCase extends UnitTestCase {
|
||||
$this->skipUnless(FALSE, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias to the method in PHPUnit
|
||||
*
|
||||
* @param string $message
|
||||
*/
|
||||
public function expectExceptionMessage($message)
|
||||
{
|
||||
// noop
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias for phpunit method
|
||||
*
|
||||
@ -104,7 +132,7 @@ abstract class Query_TestCase extends UnitTestCase {
|
||||
*/
|
||||
public function setExpectedException($name, $message='', $code=NULL)
|
||||
{
|
||||
$this->expectException($name);
|
||||
$this->expectException($name, $message);
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,9 +145,6 @@ define('QTEST_DIR', __DIR__);
|
||||
define('QBASE_DIR', realpath(__DIR__ . '/../') . '/');
|
||||
define('QDS', DIRECTORY_SEPARATOR);
|
||||
|
||||
// Include db classes
|
||||
require_once(QBASE_DIR . 'autoload.php');
|
||||
|
||||
// Include db tests
|
||||
// Load db classes based on capability
|
||||
$test_path = QTEST_DIR.'/databases/';
|
||||
@ -142,7 +167,7 @@ $driver_test_map = array(
|
||||
'MySQL' => in_array('mysql', $drivers),
|
||||
'SQLite' => in_array('sqlite', $drivers),
|
||||
'PgSQL' => in_array('pgsql', $drivers),
|
||||
//'Firebird' => in_array('interbase', $drivers),
|
||||
'Firebird' => in_array('interbase', $drivers),
|
||||
//'PDOFirebird' => in_array('firebird', $drivers)
|
||||
);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user