Merge branch 'master' of https://git.mcnd.ca/mcndave/ulmus
This commit is contained in:
		
						commit
						fa4e686f35
					
				| @ -82,27 +82,7 @@ class PdoObject extends PDO { | ||||
|                 $this->beginTransaction(); | ||||
|             } | ||||
| 
 | ||||
|             foreach($parameters as $key => $value) { | ||||
|                 switch(strtolower(gettype($value))) { | ||||
|                     case "boolean": | ||||
|                         $type = Pdo::PARAM_BOOL; | ||||
|                         break; | ||||
| 
 | ||||
|                     case "integer": | ||||
|                         $type = Pdo::PARAM_INT; | ||||
|                         break; | ||||
| 
 | ||||
|                     case "null": | ||||
|                         $type = Pdo::PARAM_NULL; | ||||
|                         break; | ||||
| 
 | ||||
|                     case "string": | ||||
|                     default: | ||||
|                         $type = Pdo::PARAM_STR; | ||||
|                 } | ||||
| 
 | ||||
|                 $statement->bindValue($key, (string) $value, $type); | ||||
|             } | ||||
|             $this->bindVariables($statement, $parameters); | ||||
| 
 | ||||
|             $this->executionStatus = $statement->execute(); | ||||
| 
 | ||||
| @ -131,4 +111,36 @@ class PdoObject extends PDO { | ||||
| 
 | ||||
|         return null; | ||||
|     } | ||||
| 
 | ||||
|     protected function bindVariables(PDOStatement $statement, array &$parameters) : void | ||||
|     { | ||||
|         if ($parameters) { | ||||
|             if (array_is_list($parameters)) { | ||||
|                 $parameters = array_combine(range(1, count($parameters)), array_values($parameters)); | ||||
|             } | ||||
|             else { | ||||
|                 foreach ($parameters as $key => $value) { | ||||
|                     switch (strtolower(gettype($value))) { | ||||
|                             #$type = Pdo::PARAM_BOOL;
 | ||||
|                             #break;
 | ||||
| 
 | ||||
|                         case "boolean": | ||||
|                         case "integer": | ||||
|                             $type = Pdo::PARAM_INT; | ||||
|                             break; | ||||
| 
 | ||||
|                         case "null": | ||||
|                             $type = Pdo::PARAM_NULL; | ||||
|                             break; | ||||
| 
 | ||||
|                         case "string": | ||||
|                         default: | ||||
|                             $type = Pdo::PARAM_STR; | ||||
|                     } | ||||
| 
 | ||||
|                     $statement->bindValue($key, $value, $type); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -27,7 +27,7 @@ class Values extends Fragment { | ||||
| 
 | ||||
|         # index starts at '1' for Pdo params
 | ||||
|         $this->rows[] = array_combine(range(1, count($row)), array_values($row)); | ||||
|          | ||||
| 
 | ||||
|         return $this; | ||||
|     } | ||||
| 
 | ||||
|  | ||||
| @ -128,7 +128,7 @@ class Where extends Fragment { | ||||
|                         } | ||||
|                     } | ||||
|                     else { | ||||
|                         $stack[] = $this->filterValue(false); | ||||
|                         $stack[] = $this->filterValue(Sql::raw("(SELECT NULL WHERE FALSE)")); | ||||
|                     } | ||||
| 
 | ||||
|                     return "(" . implode(", ", $stack) . ")"; | ||||
|  | ||||
| @ -242,7 +242,7 @@ class Repository | ||||
| 
 | ||||
|         $primaryKeyDefinition = Ulmus::resolveEntity($this->entityClass)->getPrimaryKeyField(); | ||||
| 
 | ||||
|         if ( $replace || ! $entity->isLoaded() ) { | ||||
|         if ( ! $entity->isLoaded() ) { | ||||
|             # $dataset = array_filter($dataset, fn($item, $field) => ! ($this->entityResolver->searchFieldAnnotation($field, new Field, false)->readonly ?? false), \ARRAY_FILTER_USE_BOTH);
 | ||||
| 
 | ||||
|             $statement = $this->insertSqlQuery($fieldsAndValue ?? $dataset, $replace)->runInsertQuery(); | ||||
| @ -277,6 +277,8 @@ class Repository | ||||
|                 return $update ? (bool) $update->rowCount : false; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return 0; | ||||
|     } | ||||
| 
 | ||||
|     public function replace(object|array $entity, ? array $fieldsAndValue = null) : bool | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user