- Work done on Repository and QueryBuilder -- fixed some minor bugs and added some delete() functions
- Added a generic SQL query function to PDOObject
This commit is contained in:
1 parent
b589ba3c2b
commit
9df7e65dcf
10 files changed
+139
-31
No files matched your search
@@ -9,6 +9,7 @@ use Ulmus\Annotation\Annotation,
|
||||
class EntityResolver {
|
||||
|
||||
const KEY_ENTITY_NAME = 01;
|
||||
|
||||
const KEY_COLUMN_NAME = 02;
|
||||
|
||||
public string $entityClass;
|
||||
@@ -51,7 +52,7 @@ class EntityResolver {
|
||||
public function fieldList($fieldKey = self::KEY_ENTITY_NAME) : array
|
||||
{
|
||||
$fieldList = [];
|
||||
|
||||
|
||||
foreach($this->properties as $item) {
|
||||
foreach($item['tags'] ?? [] as $tag) {
|
||||
if ( $tag['object'] instanceof Field ) {
|
||||
@@ -73,7 +74,7 @@ class EntityResolver {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $fieldList;
|
||||
}
|
||||
|
||||
@@ -100,15 +101,15 @@ class EntityResolver {
|
||||
*/
|
||||
public function getAnnotationFromClassname(string $className) : ? object
|
||||
{
|
||||
if ( $name = $this->uses[$className] ?? false) {
|
||||
if ( $name = $this->uses[$className] ?? false ) {
|
||||
|
||||
foreach($this->class['tags'] as $item) {
|
||||
foreach(array_reverse($this->class['tags']) as $item) {
|
||||
if ( $item['tag'] === $name ) {
|
||||
return $this->instanciateAnnotationObject($item);
|
||||
}
|
||||
|
||||
foreach($this->properties as $item) {
|
||||
foreach($item['tags'] as $item) {
|
||||
foreach(array_reverse($item['tags']) as $item) {
|
||||
if ( $item['tag'] === $name ) {
|
||||
return $this->instanciateAnnotationObject($item);
|
||||
}
|
||||
@@ -116,7 +117,7 @@ class EntityResolver {
|
||||
}
|
||||
|
||||
foreach($this->methods as $item) {
|
||||
foreach($item['tags'] as $item) {
|
||||
foreach(array_reverse($item['tags']) as $item) {
|
||||
if ( $item['tag'] === $name ) {
|
||||
return $this->instanciateAnnotationObject($item);
|
||||
}
|
||||
|
||||
@@ -57,18 +57,18 @@ class ObjectReflection {
|
||||
if ( $parentClass = $this->classReflection->getParentClass() ) {
|
||||
$class = static::fromClass($parentClass)->gatherClass(true);
|
||||
}
|
||||
|
||||
|
||||
$itemName = function($item) {
|
||||
return $item->getName();
|
||||
};
|
||||
}
|
||||
|
||||
return [
|
||||
'tags' => array_merge($class, $this->annotationReader->getClass($this->classReflection))
|
||||
return array_merge_recursive($class, [
|
||||
'tags' => $this->annotationReader->getClass($this->classReflection)
|
||||
] + ( ! $full ? [] : [
|
||||
'traits' => array_map($itemName, $this->classReflection->getTraits()),
|
||||
'interfaces' => array_map($itemName, $this->classReflection->getInterfaces()),
|
||||
]);
|
||||
]));
|
||||
}
|
||||
|
||||
public function gatherProperties(bool $full = true, int $filter =
|
||||
@@ -86,11 +86,9 @@ class ObjectReflection {
|
||||
}
|
||||
}
|
||||
|
||||
$properties = array_merge($properties, $this->classReflection->getProperties($filter));
|
||||
|
||||
$list = [];
|
||||
|
||||
foreach($properties as $property) {
|
||||
foreach($this->classReflection->getProperties($filter) as $property) {
|
||||
$current = [
|
||||
'name' => $property->getName()
|
||||
];
|
||||
@@ -111,10 +109,10 @@ class ObjectReflection {
|
||||
continue;
|
||||
}
|
||||
|
||||
$list[ $current['name'] ] = $current;
|
||||
$list[ $current['name'] ] = $current;
|
||||
}
|
||||
|
||||
return $list;
|
||||
return array_merge($properties, $list);
|
||||
}
|
||||
|
||||
public function gatherMethods(bool $full = true, int $filter =
|
||||
@@ -131,12 +129,10 @@ class ObjectReflection {
|
||||
$methods = static::fromClass($parentClass)->gatherMethods($full, $filter);
|
||||
}
|
||||
}
|
||||
|
||||
$methods = array_merge($methods, $this->classReflection->getMethods($filter));
|
||||
|
||||
foreach($methods as $method) {
|
||||
|
||||
foreach($this->classReflection->getMethods($filter) as $method) {
|
||||
$parameters = [];
|
||||
|
||||
|
||||
foreach($method->getParameters() as $parameter) {
|
||||
$parameters[$parameter->getName()] = [
|
||||
'null' => $parameter->allowsNull(),
|
||||
@@ -166,7 +162,7 @@ class ObjectReflection {
|
||||
$list[ $current['name'] ] = $current;
|
||||
}
|
||||
|
||||
return $list;
|
||||
return array_merge($methods, $list);
|
||||
}
|
||||
|
||||
protected function ignoreElementAnnotation($tags) : bool
|
||||
|
||||
@@ -9,7 +9,7 @@ class PdoObject extends PDO {
|
||||
public function select(string $sql, array $parameters = []) : PDOStatement
|
||||
{
|
||||
try {
|
||||
if ( $statement = $this->prepare($sql) ) {
|
||||
if ( false !== ( $statement = $this->prepare($sql) ) ) {
|
||||
$statement = $this->execute($statement, $parameters, true);
|
||||
$statement->setFetchMode(\PDO::FETCH_ASSOC);
|
||||
return $statement;
|
||||
@@ -17,6 +17,16 @@ class PdoObject extends PDO {
|
||||
} catch (\PDOException $e) { throw $e; }
|
||||
}
|
||||
|
||||
public function runQuery(string $sql, array $parameters = []) : PDOStatement
|
||||
{
|
||||
# var_dump($sql, $parameters);die();
|
||||
try {
|
||||
if ( false !== ( $statement = $this->prepare($sql) ) ) {
|
||||
return $this->execute($statement, $parameters, true);
|
||||
}
|
||||
} catch (\PDOException $e) { throw $e; }
|
||||
}
|
||||
|
||||
public function execute(PDOStatement $statement, array $parameters = [], bool $commit = true) : ? PDOStatement
|
||||
{
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user