Browse Source

Remove some old code coupling and boilerplate

keep-around/73e4c35163f3579f2dbaf2971ca707928f58f541
Timothy Warren 1 year ago
parent
commit
73e4c35163
2 changed files with 8 additions and 28 deletions
  1. +1
    -1
      phpdox.xml
  2. +7
    -27
      src/QueryBuilder.php

+ 1
- 1
phpdox.xml View File

@@ -35,7 +35,7 @@
-->

<!-- Additional configuration for the collecting process (parsing of php code, generation of xml data) -->
<collector publiconly="false" backend="parser" encoding="auto">
<collector publiconly="true" backend="parser" encoding="auto">
<!-- @publiconly - Flag to disable/enable processing of non public methods and members -->
<!-- @backend - The collector backend to use, currently only shipping with 'parser' -->
<!-- @encoding - Charset encoding of source files (overwrite default 'auto' if detection fails) -->

+ 7
- 27
src/QueryBuilder.php View File

@@ -16,11 +16,7 @@ namespace Query;

use BadMethodCallException;
use PDOStatement;
use Query\Drivers\{
AbstractUtil,
DriverInterface,
SQLInterface
};
use Query\Drivers\DriverInterface;

/**
* Convenience class for creating sql queries
@@ -37,7 +33,9 @@ class QueryBuilder implements QueryBuilderInterface {
* List of queries executed
* @var array
*/
public $queries;
public $queries = [
'total_time' => 0
];

/**
* Whether to do only an explain on the query
@@ -57,18 +55,6 @@ class QueryBuilder implements QueryBuilderInterface {
*/
protected $parser;

/**
* Alias to driver util class
* @var AbstractUtil
*/
protected $util;

/**
* Alias to driver sql class
* @var SQLInterface
*/
protected $sql;

/**
* Query Builder state
* @var State
@@ -93,12 +79,6 @@ class QueryBuilder implements QueryBuilderInterface {

// Create new State object
$this->state = new State();

$this->queries['total_time'] = 0;

// Alias driver sql and util classes
$this->sql = $this->driver->getSql();
$this->util = $this->driver->getUtil();
}

/**
@@ -543,7 +523,7 @@ class QueryBuilder implements QueryBuilderInterface {
// doesn't support random ordering
if (stripos($type, 'rand') !== FALSE)
{
$rand = $this->sql->random();
$rand = $this->driver->getSql()->random();
$type = $rand ?? 'ASC';
}

@@ -1306,14 +1286,14 @@ class QueryBuilder implements QueryBuilderInterface {
$limit = $this->state->getLimit();
if (is_numeric($limit))
{
$sql = $this->sql->limit($sql, $limit, $this->state->getOffset());
$sql = $this->driver->getSql()->limit($sql, $limit, $this->state->getOffset());
}

// See if the query plan, rather than the
// query data should be returned
if ($this->explain === TRUE)
{
$sql = $this->sql->explain($sql);
$sql = $this->driver->getSql()->explain($sql);
}

return $sql;

Loading…
Cancel
Save