/** * Returns a string containing the field names seperated by commas * * @return string The field list as string */ public function getColumns() { $names = array(); foreach ($this->_sql->getFieldNames() as $field => $placeholder) { $names[] = "`{$field}`={$placeholder}"; } return implode(', ', $names); }
/** * Returns the group by clause for this query * * @return string The group by clause string */ public function getGroupBy() { $template = "GROUP BY %s"; $groupBy = null; if (!is_null($this->_sql->groupBy)) { $groupBy = trim(sprintf($template, $this->_sql->getGroupBy())); } return $groupBy; }
/** * Generate constraints for foreign keys for this create table statement * @return string */ protected function _getConstraints($pre = '') { $foreignKeys = $this->_sql->getForeignKeys(); $items = array(); $template = <<<EOS %sCONSTRAINT `%s` FOREIGN KEY (`%s`) REFERENCES `%s` (`%s`) ON DELETE %s ON UPDATE %s EOS; foreach ($foreignKeys as $foreignKey) { $onDelete = $this->_getOnAction($foreignKey->onDelete); $onUpdate = $this->_getOnAction($foreignKey->onUpdate); $fks = array_keys($foreignKey->indexColumns); $items[] = sprintf($template, $pre, $foreignKey->name, $fks[0], $foreignKey->referencedTable, $foreignKey->indexColumns[$fks[0]], $onDelete, $onUpdate); } if (sizeof($foreignKeys) > 0) { return ",\n" . implode(",\n", $items); } return null; }
/** * Returns a string containing the placeholders for query execute * * @return string The placeholders for query execute */ public function getValues() { $keys = $this->_sql->getFieldNames(); return implode(', ', $keys); }
/** * Returns the SQL query string for current Select SQL Object * * @return String The SQL query string */ public function getStatement() { return trim(sprintf($this->_delete, $this->_sql->getTableName(), $this->getWhere())); }