mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-16 08:28:41 +00:00
Fixing minor bugs for insert, such as accessibility and query building in loops.
This commit is contained in:
parent
fdef759d37
commit
e247c6a627
|
|
@ -249,7 +249,9 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
|
|
||||||
foreach ($properties as $property) {
|
foreach ($properties as $property) {
|
||||||
foreach (static::$columns as $key => $column) {
|
foreach (static::$columns as $key => $column) {
|
||||||
if ($column['internal'] === $property) {
|
if ($column['internal'] === $property->getName()) {
|
||||||
|
$property->setAccessible(true);
|
||||||
|
|
||||||
$value = $property->getValue($obj);
|
$value = $property->getValue($obj);
|
||||||
|
|
||||||
if ($column['type'] === 'DateTime') {
|
if ($column['type'] === 'DateTime') {
|
||||||
|
|
@ -257,7 +259,9 @@ abstract class DataMapperAbstract implements DataMapperInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
$query->insert($column['name'])
|
$query->insert($column['name'])
|
||||||
->values($value);
|
->value($value);
|
||||||
|
|
||||||
|
// todo: do i have to reverse the accessibility or is there no risk involved here?
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
namespace phpOMS\DataStorage\Database\Query;
|
namespace phpOMS\DataStorage\Database\Query;
|
||||||
|
|
||||||
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
|
use phpOMS\DataStorage\Database\Connection\ConnectionAbstract;
|
||||||
|
use phpOMS\DataStorage\Database\Query;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database query builder.
|
* Database query builder.
|
||||||
|
|
@ -174,7 +175,7 @@ class Builder
|
||||||
* @var QueryType
|
* @var QueryType
|
||||||
* @since 1.0.0
|
* @since 1.0.0
|
||||||
*/
|
*/
|
||||||
protected $type = null;
|
protected $type = QueryType::INSERT;
|
||||||
|
|
||||||
protected $unionLimit = null;
|
protected $unionLimit = null;
|
||||||
|
|
||||||
|
|
@ -792,6 +793,26 @@ class Builder
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Values to insert.
|
||||||
|
*
|
||||||
|
* @param mixed $value Values
|
||||||
|
*
|
||||||
|
* @return Builder
|
||||||
|
*
|
||||||
|
* @since 1.0.0
|
||||||
|
* @author Dennis Eichhorn <d.eichhorn@oms.com>
|
||||||
|
*/
|
||||||
|
public function value($value) : Builder
|
||||||
|
{
|
||||||
|
end($this->values);
|
||||||
|
$key = key($this->values);
|
||||||
|
$this->values[$key][] = $value;
|
||||||
|
reset($this->values);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
public function update() : Builder
|
public function update() : Builder
|
||||||
{
|
{
|
||||||
$this->type = QueryType::UPDATE;
|
$this->type = QueryType::UPDATE;
|
||||||
|
|
@ -877,7 +898,8 @@ class Builder
|
||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function merge($query) : Builder {
|
public function merge($query) : Builder
|
||||||
|
{
|
||||||
return clone($this);
|
return clone($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -169,10 +169,10 @@ class Grammar extends \phpOMS\DataStorage\Database\Grammar
|
||||||
$components = $this->insertComponents;
|
$components = $this->insertComponents;
|
||||||
break;
|
break;
|
||||||
case QueryType::UPDATE:
|
case QueryType::UPDATE:
|
||||||
$components = null;
|
$components = [];
|
||||||
break;
|
break;
|
||||||
case QueryType::DELETE:
|
case QueryType::DELETE:
|
||||||
$components = null;
|
$components = [];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new \InvalidArgumentException('Unknown query type.');
|
throw new \InvalidArgumentException('Unknown query type.');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user