public function execute(QueryContext $context)
 {
     if (!$this->forceDelete && $this->schema->getSoftDelete()) {
         $executor = TableQueryExecutor::makeUpdate($this->schema, array(TableSchema::SOFT_DELETE_FIELD => time()), $this->conditions);
         return $executor->execute($context);
     }
     $query = $this->toQueryString($context);
     return DB::delete($query, $context->getParams());
 }
Ejemplo n.º 2
0
 public function getQueryString(QueryContext $context)
 {
     if (!$this->subQuery) {
         if ($this->subQueryLimit) {
             throw new QueryException("Must be sub-query in [" . ConditionQueryBuilder::toString($context, $this->conditions) . "]");
         }
         return ConditionQueryBuilder::toString($context, $this->conditions);
     } else {
         $context->schema($this->subQueryTableSchema);
         if (!$this->softDeleteLess && $this->subQueryTableSchema->getSoftDelete()) {
             $this->addCondition(ConditionInfo::make(ConditionInfo::CONDITION_AND, WhereConditionBuilder::makeNormal($this->subQueryTableSchema->getFieldSymbol(TableSchema::SOFT_DELETE_FIELD, false), '=', 0)));
         }
         $statements = array();
         $statements[] = SelectionQueryBuilder::toString($context, $this->selectFields);
         $statements[] = 'FROM ' . $this->subQueryTableSchema->getSymbol();
         $condition = ConditionQueryBuilder::toString($context, $this->conditions);
         if (isset($condition)) {
             $statements[] = "WHERE " . $condition;
         }
         return implode(' ', $statements);
     }
 }