/** * @param Delete $delete * * @return string */ public function write(Delete $delete) { $table = $this->writer->writeTable($delete->getTable()); $parts = array("DELETE FROM {$table}"); AbstractBaseWriter::writeWhereCondition($delete, $this->writer, $this->placeholderWriter, $parts); AbstractBaseWriter::writeLimitCondition($delete, $this->placeholderWriter, $parts); $comment = AbstractBaseWriter::writeQueryComment($delete); return $comment . implode(" ", $parts); }
/** * @test */ public function itShouldWriteDeleteRowWithWhereConditionAndLimit1() { $this->query->setTable('user'); $conditions = $this->query->where(); $conditions->equals('user_id', 10)->equals('user_id', 20)->equals('user_id', 30); $this->query->limit(1); $expected = <<<SQL DELETE FROM user WHERE (user.user_id = :v1) AND (user.user_id = :v2) AND (user.user_id = :v3) LIMIT :v4 SQL; $this->assertSame($expected, $this->writer->write($this->query)); $expected = array(':v1' => 10, ':v2' => 20, ':v3' => 30, ':v4' => 1); $this->assertEquals($expected, $this->writer->getValues()); }
/** * @test */ public function itShouldReturnLimit1() { $this->query->limit(1); $this->assertSame(1, $this->query->getLimitStart()); }