//else那段实际已经多余了
//原来支持吗?

/**
* 生成delete SQL
* @access public
* @param array $options 表达式
* @return string
*/
public function delete($options)
{
//protected $deleteTablesSql = 'DELETE %TABLE% FROM %TABLE0% %USING% %JOIN% %WHERE% %ORDER%%LIMIT% %LOCK%%COMMENT%';
/*示例
Db::table(['__ORDER__' => 'a', '__ORDER_GOODS__' => 'g'])
->join('__ORDER_GOODS__ g', 'a.id = g.oid', 'left')
->where('a.status='.$this->orderStatusNoPay.' and a.cuid='.$uid)->delete();
*/
$table = $this->parseTable($options['table'], $options);
$tables = explode(',', $table);
$table = '';
foreach($tables as $v){
$temp = explode(' ', $v);
if(isset($temp[1])){
$table .= ','.$temp[1];
}else{
$table .= ','.$temp[0];
}
}
$table = trim($table, ',');
$sql = str_replace(
['%TABLE%', '%TABLE0%', '%USING%', '%JOIN%', '%WHERE%', '%ORDER%', '%LIMIT%', '%LOCK%', '%COMMENT%'],
[
$table,
$tables[0],
!empty($options['using']) ? ' USING ' . $this->parseTable($options['using'], $options) . ' ' : '',
$this->parseJoin($options['join'], $options),
$this->parseWhere($options['where'], $options),
$this->parseOrder($options['order'], $options),
$this->parseLimit($options['limit']),
$this->parseLock($options['lock']),
$this->parseComment($options['comment']),
], $this->deleteTablesSql);
return $sql;
} 最佳答案