Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/gh56 move statements to object based #61

Closed
wants to merge 26 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c6f7f1f
..
gin0115 Feb 12, 2022
e997f97
Merge branch 'develop' into feature/gh56-move-statements-to-object-based
gin0115 Feb 12, 2022
3e5da36
basis of select statement added with tests
gin0115 Feb 12, 2022
7f8e868
House Keeping
gin0115 Feb 12, 2022
5ae5e08
House Keeping
gin0115 Feb 12, 2022
7bbdebe
created basic table statement with unit tests
gin0115 Feb 12, 2022
09bc48f
added in collection tests
gin0115 Feb 12, 2022
287c8d9
Select correclty being parsed with all prefixing and parseing happeni…
gin0115 Feb 13, 2022
9bda5af
House Keeping
gin0115 Feb 13, 2022
158207c
Table statements now with parser and normalizer
gin0115 Feb 15, 2022
71c5e30
House Keeping
gin0115 Feb 15, 2022
8940cab
orderby now works with the flexible key value relationship. Helper me…
gin0115 Feb 16, 2022
177d071
House Keeping
gin0115 Feb 16, 2022
454a67d
House Keeping
gin0115 Feb 16, 2022
92a6c19
added in groupby with basic tests
gin0115 Feb 16, 2022
85d4015
House Keeping
gin0115 Feb 16, 2022
c64f3af
House Keeping
gin0115 Feb 16, 2022
ecaf00c
House Keeping
gin0115 Feb 16, 2022
8c86bb3
Reneamed statementCollection to StatementBuilder
gin0115 Feb 16, 2022
585f4c7
House Keeping
gin0115 Feb 20, 2022
2b00c8b
Where criteria builder now in place
gin0115 Feb 23, 2022
e6b5964
having
gin0115 Feb 24, 2022
38d6326
Join statement done
gin0115 Feb 27, 2022
aab02b2
Clean up for join
gin0115 Feb 27, 2022
cb5e75d
Stashed
gin0115 Apr 15, 2022
2f5e63a
Merge branch 'develop' into feature/gh56-move-statements-to-object-based
gin0115 Apr 17, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/tests export-ignore
/phpunit.xml.dist export-ignore
/.scrutinizer.yml export-ignore
/.php-cs-fixer.php export-ignore
/codecov.yml export-ignore
/phpstan.neon.dist export-ignore
/static-loader-creator.php export-ignore
/src/loader.php export-ignore
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ $thing = QB::table('someTable')->where('something','=', 'something else')->first

## Perquisites

* WordPress 5.7+ (tested upto 5.9)
* PHP 7.1+ (includes support for PHP8)
* MySql 5.7+ or MariaDB 10.2+
* WordPress 5.6+ `(tested on 5.6, 5.7, 5.8, 5.9)`
* PHP 7.1+ `(tested on 7.1, 7.2, 7.3, 7.4, 8.0, 8.1)`
* MySql 5.7+ `(tested on 5.7)` or MariaDB 10.2+ `(tested on 10.2, 10.3, 10.4, 10.5, 10.6, 10.7)`
* Composer (optional)

## Using Composer
Expand Down
1 change: 1 addition & 0 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Connection
public const PREFIX = 'prefix';
public const SHOW_ERRORS = 'show_errors';
public const USE_WPDB_PREFIX = 'use_wpdb_prefix';
public const THROW_ERRORS = 'throw_errors';

/**
* @var string
Expand Down
33 changes: 33 additions & 0 deletions src/Exception/WpdbException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

/**
* Exception for errors during WPDB operations.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @since 0.0.2
* @author Glynn Quelch <[email protected]>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @package Gin0115\Pixie
* @subpackage Exception
*/

namespace Pixie\Exception;

use Pixie\Exception;

class WpdbException extends Exception
{
}
2 changes: 1 addition & 1 deletion src/JSON/JsonHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class JsonHandler
public function __construct(Connection $connection)
{
$this->connection = $connection;
$this->jsonSelectorHandler = new JsonSelectorHandler($connection);
$this->jsonSelectorHandler = new JsonSelectorHandler();
$this->jsonExpressionFactory = new JsonExpressionFactory($connection);
}

Expand Down
25 changes: 1 addition & 24 deletions src/JSON/JsonSelectorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,9 @@
namespace Pixie\JSON;

use Pixie\Exception;
use Pixie\Connection;
use Pixie\HasConnection;
use Pixie\QueryBuilder\TablePrefixer;

class JsonSelectorHandler implements HasConnection
class JsonSelectorHandler
{
use TablePrefixer;

/** @var Connection */
protected $connection;

public function __construct(Connection $connection)
{
$this->connection = $connection;
}

/**
* Returns the current connection instance.
*
* @return connection
*/
public function getConnection(): Connection
{
return $this->connection;
}

/**
* Checks if the passed expression is for JSON
* this->denotes->json
Expand Down
74 changes: 74 additions & 0 deletions src/Parser/Criteria.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

declare(strict_types=1);

/**
* Model of a criteria
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* @since 0.0.2
* @author Glynn Quelch <[email protected]>
* @license http://www.opensource.org/licenses/mit-license.html MIT License
* @package Gin0115\Pixie
* @subpackage Parser
*/

namespace Pixie\Parser;

class Criteria
{
/**
* The SQL statement
*
* @var string
*/
protected $statement;

/**
* The bindings for the statement
*
* @var array<int, string|int|float|bool|null>
*/
protected $bindings;

/**
* @param string $statement
* @param array<int, string|int|float|bool|null> $bindings
*/
public function __construct(string $statement, array $bindings)
{
$this->statement = $statement;
$this->bindings = $bindings;
}

/**
* Get the SQL statement
*
* @return string
*/
public function getStatement(): string
{
return $this->statement;
}

/**
* Get the bindings
*
* @return array<int, string|int|float|bool|null>
*/
public function getBindings(): array
{
return $this->bindings;
}
}
Loading