/** * Builds an SQL compatible order by query portion. * Note: does not include the 'ORDER BY' word as a query can be composed of multiple order by clauses. * @return String the order by clause query string */ public function toSQL() { return Inform8Context::getDbConnection()->real_escape_string($this->table) . '.' . Inform8Context::getDbConnection()->real_escape_string($this->field) . ' ' . Inform8Context::getDbConnection()->real_escape_string($this->direction); }
/** * Creates an SQL query portion representing this condition. * @return String the condition in SQL */ public function toSQL() { return Inform8Context::getDbConnection()->real_escape_string($this->table) . '.' . Inform8Context::getDbConnection()->real_escape_string($this->field) . ' ' . Inform8Context::getDbConnection()->real_escape_string($this->condition) . ' ' . "'" . Inform8Context::getDbConnection()->real_escape_string($this->value) . "'"; }
function __construct() { $this->mysqli = Inform8Context::getDbConnection(); $this->logger = Inform8Context::getLogger(); }
public function buildQuery() { $query = "SELECT "; if ($this->distinct) { $query .= ' DISTINCT '; } $comma = false; foreach ($this->fields as $field) { if ($comma) { $query .= ', '; } else { $comma = true; } $query .= Inform8Context::getDbConnection()->real_escape_string($this->table . '.' . $field); } $query .= " FROM " . Inform8Context::getDbConnection()->real_escape_string($this->table); foreach ($this->joins as $join) { $query .= ', ' . Inform8Context::getDbConnection()->real_escape_string($join->getOtherTable()); } $query .= $this->buildWhere(); $query .= $this->buildOrderBy(); if ($this->limit > 0) { $query .= " LIMIT " . $this->start . ',' . $this->limit; } return $query; }