示例#1
0
 /**
  * Returns the "DELETE FROM <table> [AS <alias>]" part of DELETE query.
  *
  * @param Criteria $criteria
  * @param string   $tableName
  *
  * @return string
  */
 public function getDeleteFromClause(Criteria $criteria, $tableName)
 {
     $sql = 'DELETE ';
     if ($queryComment = $criteria->getComment()) {
         $sql .= '/* ' . $queryComment . ' */ ';
     }
     if ($realTableName = $criteria->getTableForAlias($tableName)) {
         if ($this->useQuoteIdentifier()) {
             $realTableName = $this->quoteIdentifierTable($realTableName);
         }
         $sql .= $tableName . ' FROM ' . $realTableName . ' AS ' . $tableName;
     } else {
         if ($this->useQuoteIdentifier()) {
             $tableName = $this->quoteIdentifierTable($tableName);
         }
         $sql .= 'FROM ' . $tableName;
     }
     return $sql;
 }
示例#2
0
 public function testComment()
 {
     $c = new Criteria();
     $this->assertNull($c->getComment(), 'Comment is null by default');
     $c2 = $c->setComment('foo');
     $this->assertEquals('foo', $c->getComment(), 'Comment is set by setComment()');
     $this->assertEquals($c, $c2, 'setComment() returns the current Criteria');
     $c->setComment();
     $this->assertNull($c->getComment(), 'Comment is reset by setComment(null)');
 }