public function SelectQuery::__toString in Salesforce Suite 8.4
Same name and namespace in other branches
- 8.3 src/SelectQuery.php \Drupal\salesforce\SelectQuery::__toString()
- 5.0.x src/SelectQuery.php \Drupal\salesforce\SelectQuery::__toString()
Return the query as a string.
Return value
string The url-encoded query string.
Overrides SelectQueryInterface::__toString
File
- src/
SelectQuery.php, line 101
Class
- SelectQuery
- Class SelectQuery.
Namespace
Drupal\salesforceCode
public function __toString() {
$query = 'SELECT+';
$query .= implode(',', array_unique($this->fields));
$query .= "+FROM+" . $this->objectType;
if (count($this->conditions) > 0) {
$where = [];
foreach ($this->conditions as $condition) {
$where[] = implode('+', $condition);
}
$query .= '+WHERE+' . implode('+AND+', $where);
}
if ($this->order) {
$query .= "+ORDER BY+";
$fields = [];
foreach ($this->order as $field => $direction) {
$fields[] = $field . ' ' . $direction;
}
$query .= implode(',+', $fields);
}
if ($this->limit) {
$query .= "+LIMIT+" . (int) $this->limit;
}
return $query;
}