Initial xentral_oss_20.3.c9ffacf

This commit is contained in:
Alex
2021-05-21 08:49:41 +02:00
parent 5406e4a551
commit 34e5ac43d9
18884 changed files with 2109867 additions and 0 deletions
@@ -0,0 +1,9 @@
<?php
namespace Xentral\Components\Database\SqlQuery;
use Aura\SqlQuery\Mysql\Delete;
final class DeleteQuery extends Delete
{
}
@@ -0,0 +1,9 @@
<?php
namespace Xentral\Components\Database\SqlQuery;
use Aura\SqlQuery\Mysql\Insert;
final class InsertQuery extends Insert
{
}
@@ -0,0 +1,59 @@
<?php
namespace Xentral\Components\Database\SqlQuery;
use Aura\SqlQuery\AbstractQuery;
use Aura\SqlQuery\QueryFactory as AuraQueryFactory;
final class QueryFactory extends AuraQueryFactory
{
/**
* @return SelectQuery
*/
public function newSelect()
{
return $this->newInstance('Select');
}
/**
* @return InsertQuery
*/
public function newInsert()
{
$insert = $this->newInstance('Insert');
$insert->setLastInsertIdNames($this->last_insert_id_names);
return $insert;
}
/**
* @return UpdateQuery
*/
public function newUpdate()
{
return $this->newInstance('Update');
}
/**
* @return DeleteQuery
*/
public function newDelete()
{
return $this->newInstance('Delete');
}
/**
* @param string $query The query object type.
*
* @return AbstractQuery
*/
protected function newInstance($query)
{
$class = "Xentral\\Components\\Database\\SqlQuery\\{$query}Query";
return new $class(
$this->getQuoter(),
$this->newSeqBindPrefix()
);
}
}
@@ -0,0 +1,85 @@
<?php
namespace Xentral\Components\Database\SqlQuery;
use Aura\SqlQuery\Mysql\Select;
use Closure;
final class SelectQuery extends Select
{
/**
* @return bool
*/
public function hasOrderBy()
{
return !empty($this->order_by);
}
/**
* @param string $andor
* @param array|callable $args
*
* @return Select
*/
protected function addWhere($andor, $args)
{
if ($args[0] instanceof Closure) {
$this->addClauseCondClosure('where', $andor, $args[0]);
return $this;
}
return parent::addWhere($andor, $args);
}
/**
* Aura.SqlQuery 2.x unterstützt keine Klammersetzung in WHERE-Bedingungen
*
* @see https://github.com/auraphp/Aura.SqlQuery/issues/97
*
* Feature aus Version 3 importiert: https://github.com/auraphp/Aura.SqlQuery/pull/136/files
*
* @copyright Paul M. Jones
* @license MIT
*
* @param string $clause
* @param string $andor
* @param callable $closure
*/
protected function addClauseCondClosure($clause, $andor, $closure)
{
// retain the prior set of conditions, and temporarily reset the clause
// for the closure to work with (otherwise there will be an extraneous
// opening AND/OR keyword)
$set = $this->$clause;
$this->$clause = [];
// invoke the closure, which will re-populate the $this->$clause
$closure($this);
// are there new clause elements?
if (!$this->$clause) {
// no: restore the old ones, and done
$this->$clause = $set;
return;
}
// append an opening parenthesis to the prior set of conditions,
// with AND/OR as needed ...
if ($set) {
$set[] = "{$andor} (";
} else {
$set[] = "(";
}
// append the new conditions to the set, with indenting
foreach ($this->$clause as $cond) {
$set[] = " {$cond}";
}
$set[] = ")";
// ... then put the full set of conditions back into $this->$clause
$this->$clause = $set;
}
}
@@ -0,0 +1,9 @@
<?php
namespace Xentral\Components\Database\SqlQuery;
use Aura\SqlQuery\Mysql\Update;
final class UpdateQuery extends Update
{
}