|
|
@@ -32,7 +32,6 @@ class QueryCompiler {
|
|
|
* @var array
|
|
|
*/
|
|
|
protected $_templates = [
|
|
|
- 'delete' => 'DELETE',
|
|
|
'update' => 'UPDATE %s',
|
|
|
'where' => ' WHERE %s',
|
|
|
'group' => ' GROUP BY %s ',
|
|
|
@@ -160,6 +159,30 @@ class QueryCompiler {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * Helper function used to build the string representation of a DELETE clause.
|
|
|
+ *
|
|
|
+ * If the table is aliased, a `DELETE x` fragment will be returned
|
|
|
+ *
|
|
|
+ * @param array $parts list of tables to be transformed to string
|
|
|
+ * @param \Cake\Database\Query $query The query that is being compiled
|
|
|
+ * @param \Cake\Database\ValueBinder $generator the placeholder generator to be used in expressions
|
|
|
+ * @return string
|
|
|
+ */
|
|
|
+ protected function _buildDeletePart($parts, $query, $generator) {
|
|
|
+ $delete = 'DELETE';
|
|
|
+ $aliases = [];
|
|
|
+ foreach ($query->clause('from') as $k => $v) {
|
|
|
+ if (is_string($k)) {
|
|
|
+ $aliases[] = $k;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!empty($aliases)) {
|
|
|
+ $delete = trim($delete . ' ' . implode(',', $aliases));
|
|
|
+ }
|
|
|
+ return $delete;
|
|
|
+ }
|
|
|
+
|
|
|
+/**
|
|
|
* Helper function used to build the string representation of a FROM clause,
|
|
|
* it constructs the tables list taking care of aliasing and
|
|
|
* converting expression objects to string.
|