[FLOW3-general] how to execute a DELETE-Statement?

Steffen Wickham steffen at gaming-inc.de
Tue Apr 2 13:05:16 CEST 2013


Hello Winfried,

there is a remove() method within the basic
\TYPO3\Flow\Persistance\Repository class where you derive your specific
Repository class from. Just pass your object als parameter to it and it
will be deleted immediatly.
So just add a new method to your Repository where you select all data
and pass them to the remove method after that.

I hadn't tested yet put this could be a solution (only method body):
$query = $this->createQuery();

$inactiveObjects = $query->matching(
$query->logicalOr($query->equals('active', NULL),
$query->equals('active','')) );
foreach ($inactiveObjects as $object) {
    $this->remove($object);
}

Yours,
Steffen



Am 02.04.13 11:55, schrieb Winfried Mingst:
> Hi,
>
> how can I execute a DELETE-Statement?
> The SQL-Statement is: "DELETE FROM objects as o WHERE o.active=0"
>
> In my repository I tried using this DQL-Statement:
>
>
> $query = $this->createQuery("DELETE XY\MyPackage\Model\Objects o WHERE
> o.active = ");
> $query->execute();
>
> Thanks
> Winfried
>
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general



More information about the FLOW3-general mailing list