/** * Converts this instance into a DELETE string in SQL. * * @return string */ private function getSQLForDelete() { $table = $this->_sqlParts['from']['table'] . ($this->_sqlParts['from']['alias'] ? ' ' . $this->_sqlParts['from']['alias'] : ''); $query = 'DELETE FROM ' . $table . ($this->_sqlParts['where'] !== null ? ' WHERE ' . (string) $this->_sqlParts['where'] : ''); $query = $this->_maxResults === null && $this->_firstResult == null ? $query : $this->_connection->getAdapter()->applyLimit($query, $this->_firstResult, $this->_maxResults); return $query; }
/** * Get List Table Column * * @param string $table */ private function _getListTableColumn($table) { $column = array(); $stmt = $this->_conn->query('DESCRIBE ' . $this->_conn->getAdapter()->quoteIdentifierTable($table)); $result = $stmt->fetchAll(\PDO::FETCH_ASSOC); for ($i = 0, $size = sizeof($result); $i < $size; ++$i) { $val = array_change_key_case($result[$i], CASE_LOWER); $decl = $this->getPortableDeclaration($val); $values = isset($decl['values']) ? $decl['values'] : array(); $description = array('name' => $val['field'], 'type' => $decl['php_type'], 'db_type' => $decl['type'][0], 'alltypes' => $decl['type'], 'ntype' => $val['type'], 'length' => $decl['length'], 'fixed' => (bool) $decl['fixed'], 'unsigned' => (bool) $decl['unsigned'], 'values' => $values, 'primary' => strtolower($val['key']) == 'pri', 'unique' => strtolower($val['key']) == 'uni', 'default' => $val['default'], 'notnull' => (bool) ($val['null'] != 'YES'), 'auto_increment' => (bool) (strpos($val['extra'], 'auto_increment') !== false), 'extra' => strtolower($val['extra'])); if ($description['default'] == 'CURRENT_TIMESTAMP') { $description['default'] = null; $description['notnull'] = false; $description['current_timestamp'] = true; } $column[$val['field']] = $description; } return $column; }