/** * Build and returns the full SQL SELECT query * * @return string */ public function buildQuery() { // call buildWhere() before buildTables(), to get joins ready $where = $this->where_builder->build(true); $tables = $this->tables_builder->build(); return $this->finalize($where, $tables); }
/** * Build and returns the full SQL SELECT query * * @return string */ public function buildQuery() { // Call of buildOptions() and buildWhere() before buildColumns(), as all joins must be done to // correctly deal with all properties. // Call of buildColumns() and buildWhere() before buildTables(), to get joins ready. $this->additional_where_clause = ''; // Notice : true was commented as it very often crashes mysql maintainer $where = $this->where_builder->build(); $options = $this->buildOptions(); $columns = $this->columns_builder->build(); $tables = $this->tables_builder->build(); return $this->finalize($columns, $where, $tables, $options); }
/** * Apply a restriction to the builder * * @param $builder Select * @param $class_name string * @param $restriction string|array a restriction callback */ private function applyRestriction(Select $builder, $class_name, $restriction) { if ($restriction == self::CURRENT) { $restriction = [$class_name, 'current']; } $where_array = call_user_func_array($restriction, [$class_name, $builder->getJoins()]); if ($where_array) { $where_builder = new Where($builder->getJoins()->getStartingClassName(), $where_array, $builder->getSqlLink(), $builder->getJoins()); $this->current_restrictions[] = $where_builder->build(); } }