From ed51ad45d2e2ca7f6a38b2d64826b28a79b97311 Mon Sep 17 00:00:00 2001 From: ArrayIterator Date: Sun, 14 Jul 2024 17:27:57 +0700 Subject: [PATCH] update --- Entities/Post.php | 36 +++++++++++++++++++----------------- Entities/PostCategory.php | 20 ++++++++++---------- Entities/PostMeta.php | 13 +++++++------ 3 files changed, 36 insertions(+), 33 deletions(-) diff --git a/Entities/Post.php b/Entities/Post.php index e64e52d..4c5bea2 100644 --- a/Entities/Post.php +++ b/Entities/Post.php @@ -72,15 +72,16 @@ columns: ['slug', 'site_id'] )] #[Index( + name: 'index_type_status_id_site_id', columns: [ 'type', 'status', 'site_id', 'id', - ], - name: 'index_type_status_id_site_id' + ] )] #[Index( + name: 'index_like_search_sorting', columns: [ 'title', 'site_id', @@ -93,32 +94,31 @@ 'created_at', 'deleted_at', 'password_protected', - ], - name: 'index_like_search_sorting' + ] )] #[Index( - columns: ['published_at', 'created_at'], - name: 'index_published_at_created_at' + name: 'index_published_at_created_at', + columns: ['published_at', 'created_at'] )] #[Index( - columns: ['site_id'], - name: 'relation_posts_site_id_sites_id' + name: 'relation_posts_site_id_sites_id', + columns: ['site_id'] )] #[Index( - columns: ['category_id'], - name: 'index_category_id' + name: 'index_category_id', + columns: ['category_id'] )] #[Index( - columns: ['category_id', 'site_id'], - name: 'relation_posts_category_id_post_categories_id_site_id' + name: 'relation_posts_category_id_post_categories_id_site_id', + columns: ['category_id', 'site_id'] )] #[Index( - columns: ['parent_id'], - name: 'relation_posts_parent_id_posts_id' + name: 'relation_posts_parent_id_posts_id', + columns: ['parent_id'] )] #[Index( - columns: ['user_id'], - name: 'relation_posts_user_id_admins_id' + name: 'relation_posts_user_id_admins_id', + columns: ['user_id'] )] #[HasLifecycleCallbacks] class Post extends AbstractEntity implements AvailabilityStatusEntityInterface @@ -740,10 +740,12 @@ public function checkDataEvent( $qb->set('x.category_id', ':cat_id'); $args['cat_id'] = null; } + foreach ($args as $key => $value) { + $qb->setParameter($key, $value); + } // use query builder to make sure updated_at still same $qb ->where('x.id = :id') - ->setParameters($args) ->getQuery() ->execute(); } diff --git a/Entities/PostCategory.php b/Entities/PostCategory.php index ed522f4..5a8a120 100644 --- a/Entities/PostCategory.php +++ b/Entities/PostCategory.php @@ -58,24 +58,24 @@ columns: ['slug', 'site_id'] )] #[Index( - columns: ['id', 'site_id'], - name: 'index_id_site_id' + name: 'index_id_site_id', + columns: ['id', 'site_id'] )] #[Index( - columns: ['name', 'site_id'], - name: 'index_name_site_id' + name: 'index_name_site_id', + columns: ['name', 'site_id'] )] #[Index( - columns: ['site_id'], - name: 'relation_post_categories_site_id_sites_id' + name: 'relation_post_categories_site_id_sites_id', + columns: ['site_id'] )] #[Index( - columns: ['parent_id'], - name: 'relation_post_categories_parent_id_post_categories_id' + name: 'relation_post_categories_parent_id_post_categories_id', + columns: ['parent_id'] )] #[Index( - columns: ['user_id'], - name: 'relation_post_categories_user_id_admins_id' + name: 'relation_post_categories_user_id_admins_id', + columns: ['user_id'] )] #[HasLifecycleCallbacks] class PostCategory extends AbstractEntity diff --git a/Entities/PostMeta.php b/Entities/PostMeta.php index 6c1a7df..00a0ad4 100644 --- a/Entities/PostMeta.php +++ b/Entities/PostMeta.php @@ -3,6 +3,7 @@ namespace ArrayAccess\TrayDigita\App\Modules\Posts\Entities; +use AllowDynamicProperties; use ArrayAccess\TrayDigita\Database\Entities\Abstracts\AbstractBasedMeta; use Doctrine\DBAL\Types\Types; use Doctrine\ORM\Mapping\Column; @@ -14,7 +15,7 @@ use Doctrine\ORM\Mapping\ManyToOne; use Doctrine\ORM\Mapping\Table; -#[Entity] +#[AllowDynamicProperties] #[Entity] #[Table( name: self::TABLE_NAME, options: [ @@ -29,12 +30,12 @@ ] )] #[Index( - columns: ['name'], - name: 'index_name' + name: 'index_name', + columns: ['name'] )] #[Index( - columns: ['post_id'], - name: 'relation_post_meta_post_id_posts_id' + name: 'relation_post_meta_post_id_posts_id', + columns: ['post_id'] )] #[HasLifecycleCallbacks] /** @@ -74,7 +75,7 @@ class PostMeta extends AbstractBasedMeta cascade: [ "persist", "remove", - "merge", + // "merge", "detach" ], fetch: 'EAGER'