Merge branch 'master' of https://git.mcnd.ca/mcndave/ulmus
This commit is contained in:
commit
e4767f7c09
11 files changed
+178
-55
No files matched your search
+9
-6
@@ -33,12 +33,12 @@ trait EntityTrait {
|
||||
/**entityLoadedDataset
|
||||
* @Ignore
|
||||
*/
|
||||
public function entityFillFromDataset(iterable $dataset) : self
|
||||
public function entityFillFromDataset(iterable $dataset, bool $overwriteDataset = false) : self
|
||||
{
|
||||
$loaded = $this->isLoaded();
|
||||
|
||||
|
||||
$entityResolver = $this->resolveEntity();
|
||||
|
||||
|
||||
foreach($dataset as $key => $value) {
|
||||
$field = $entityResolver->field(strtolower($key), EntityResolver::KEY_COLUMN_NAME, false) ?? null;
|
||||
|
||||
@@ -69,7 +69,7 @@ trait EntityTrait {
|
||||
$annotation = $entityResolver->searchFieldAnnotation($field['name'], new Field() );
|
||||
|
||||
if ( $annotation->length ?? null ) {
|
||||
$value = substr($value, 0, $annotation->length);
|
||||
$value = mb_substr($value, 0, $annotation->length);
|
||||
}
|
||||
}
|
||||
elseif ( $field['type'] === 'bool' ) {
|
||||
@@ -86,7 +86,7 @@ trait EntityTrait {
|
||||
throw new \Error(sprintf("%s for class '%s' on field '%s'", $e->getMessage(), get_class($this), $field['name']));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Keeping original data to diff on UPDATE query
|
||||
if ( ! $loaded /* || $isLoadedDataset */ ) {
|
||||
#if ( $field !== null ) {
|
||||
@@ -95,8 +95,11 @@ trait EntityTrait {
|
||||
#}
|
||||
$this->entityLoadedDataset = array_change_key_case($dataset, \CASE_LOWER);
|
||||
}
|
||||
elseif ($overwriteDataset) {
|
||||
$this->entityLoadedDataset = array_change_key_case($dataset, \CASE_LOWER) + $this->entityLoadedDataset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user