- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 softdelete
gedmo/doctrine-extensions 的选项但出于某种原因,当我调用 romove()
时,数据库中的记录被删除而不是更新 deletedAt
field 。
在 here , doc 告诉我们更新配置:
$config->addFilter('soft-deleteable', 'Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter');
# app/config/config.yml
doctrine:
orm:
entity_managers:
default:
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true
public function delete($id)
{
$profile = $this->profileRepository->findOneBy(['id' => $id]);
if (!$profile instanceof Profile) {
throw new ........
}
$this->entityManager->remove($profile);
$this->entityManager->flush();
return true;
}
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity()
* @ORM\Table(name="profile")
* @Gedmo\SoftDeleteable(fieldName="deletedAt")
*/
class Profile
{
/**
* @ORM\Column(name="deletedAt", type="datetime", nullable=true)
*/
private $deletedAt;
......
}
"require": {
"symfony/symfony": "2.6.*",
"doctrine/orm": "~2.2,>=2.2.3",
"doctrine/doctrine-bundle": "~1.2",
"gedmo/doctrine-extensions": "2.3.*@dev",
......
},
doctrine:
dbal:
default_connection: front
connections:
front:
driver: %database_driver%
host: %database_host%
........
back:
driver: %database_driver%
host: %database_host%
........
orm:
auto_generate_proxy_classes: %kernel.debug%
default_entity_manager: front
entity_managers:
front:
connection: front
mappings:
MyWebsiteBundle:
dir: Entity
FOSUserBundle: ~
back:
connection: back
inanzzz@inanzzz:/var/www/html/local$ php app/console doctrine:mapping:info
Found 8 mapped entities:
[OK] My\Bundle\Entity\AbstractMerchantProfile
[OK] My\Bundle\Entity\AbstractIntegration
[OK] My\Bundle\Entity\APIConsumer
[OK] My\Bundle\WebsiteBundle\Entity\User
[OK] My\Bundle\WebsiteBundle\Entity\Profile
[OK] My\Bundle\WebsiteBundle\Entity\Integration
[OK] FOS\UserBundle\Model\Group
[OK] FOS\UserBundle\Model\User
最佳答案
这就是我配置它的方式
doctrine:
dbal:
driver: "%database_driver%"
host: "%database_host%"
port: "%database_port%"
dbname: "%database_name%"
user: "%database_user%"
password: "%database_password%"
charset: UTF8
orm:
auto_generate_proxy_classes: "%kernel.debug%"
auto_mapping: true
filters:
softdeleteable:
class: Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter
enabled: true
关于symfony - DoctrineExtensions SoftDeleteable : gedmo/doctrine-extensions 的配置条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29798674/
检查这些 SO 文章后:cascade-delete-in-entity-framework , ef6-1-soft-delete-with-cascade-delete , cascading-s
我正在迁移中将软删除列添加到我的表中: public function up() { Schema::table("users", function ($table) { $t
Laravel 4.1 会在 softDeletes 时自行管理唯一索引的创建(其中 deleted_at = null)吗? 下面的方法是否正确?还是会混入已删除的记录? Schema::creat
我使用 Ef Core 2.1,我在其中启用了软删除查询过滤器。 在某些情况下,我想从一个实体中检索一个软删除的导航属性,但我无法检索到数据(导航属性为空,因为它被软删除了)。 我用了这个doc (2
我的实体 User 通过 OneToOne 关系与其他实体相关,并且我正在对所有实体进行级联“删除”。 我正在使用 SoftDeleteable 行为扩展,因此当我删除 User 时,该实体实际上并未
TLDR:当我的父模型中包含 SoftDeletes 特征时,我不再将父模型的软删除实例作为子模型的动态属性。如何做到这一点? 我定义了几个基本模型,如下所示: hasMany("App\Post")
我想知道如何将 Laravels softdelete 与 MySql foreign key restrict 约束一起使用。 框架中是否已经内置了一些东西? Softdelete 已经在工作,但我
软删除时出现以下异常。我不确定错误在哪里?谁可以帮我这个事。提前致谢 org.springframework.dao.DataIntegrityViolationException: coul
我的老板为软删除过滤器安装了这个包,但是 documentation是稀疏的。如何在我的删除查询中使用它? 最佳答案 在你的配置中启用它: stof_doctrine_extensions:
如果我有一个 PHP Doctrine 对象作为 SoftDelete,是否可以在某些查询的结果中包含已删除的项目?我正在寻找的是这样的东西...... $q = Doctrine_Query::cr
我的代码中有这些实体。 class Review extends BaseEntity { /** @ORM\OneToOne(targetEntity="Action", mappedBy=
我想制作一个使用 SoftDeletes 的特征命名 SoftDeletesWithStatus这也将更新状态列。我的问题是我想在SoftDeletes中间实现我的代码的功能是这样的: protect
我有一个出版物表,它与表评论是一对多的关系,每个出版物都有很多评论。 我在前端使用 AngularJS,在后端使用 Laravel,在数据库使用 MySQL。 假设我要softDeletes() 一个
我继承了一个使用 LLBLGen Pro 作为 DB 层的项目。 DB模型要求当一个条目被删除时有一个标志(DeletedDate设置为当前时间)。最后一个程序员忽略了这个要求,并在整个应用程序中使用
有谁知道 的替代品吗? SoftDeletable Behavior 与 兼容蛋糕 1.3.x ? 如果没有任何现成的行为可用,有关我如何在最新的 Cake 中执行此操作的任何建议? 想出了一个快速的
我可以在 ManyToMany 引用表上添加 SoftDelete 行为,这将添加一个 Deleted_at 列。不幸的是,将该列设置为非 NULL 值,不会过滤掉关系。这是我所希望的。 有人知道没有
我已将表中的主键从 id 更改为 pr_id 和 mobile。 $table->primary(['pr_id' , 'mobile']); 我还在模型中添加了 SoftDelete Trait。但
Softdelete 行为在通过实体管理器执行删除语句时工作正常,如下代码: $entity = $this->em->getRepository('Users')->find(7); $this->
当我删除带有 softDelete 列的实体时,deletedAt 和 deletedBy 为空或未设置。 如果我尝试 softRemove,它只会设置 deletedAt 标志。 下面是实体的一些代
我在来自 https://github.com/KnpLabs/DoctrineBehaviors/#softDeletable 的实体中使用 SoftDeletable 特性它工作正常,但有时我想强
我是一名优秀的程序员,十分优秀!