src/daos/sql-query-builder.php
public function get_sql() : string {
		if ( empty( $this->columns_to_select ) ) {
			// this should be the default behavior
			$this->columns_to_select = [ '*' ];
		}

		$from = ' FROM ' . implode( ', ', $this->from ) . ' ';

		if ( ! empty( $this->joins ) ) {
			$from .= $this->joins;
		}

		$from  .= 'WHERE ' . $this->where_clause;
		$select = 'SELECT ' . implode( ', ', $this->columns_to_select ) . $from;

		if ( ! empty( $this->group_by ) ) {
			$select .= 'GROUP BY ' . implode( ', ', $this->group_by ) . ' ';
		}

		if ( $this->order_by !== '' ) {
			$select .= 'ORDER BY ' . $this->order_by . ' ';
		}

		$select .= 'LIMIT ' . $this->limit;

		if ( $this->offset !== '' ) {
			$select .= ' OFFSET ' . $this->offset;
		}

		return $select;
	}
public function get_sql() : string {
		if ( empty( $this->columns_to_select ) ) {
			// this should be the default behavior
			$this->columns_to_select = [ '*' ];
		}

		$from = ' FROM ' . implode( ', ', $this->from ) . ' ';

		if ( ! empty( $this->joins ) ) {
			$from .= $this->joins;
		}

		$from  .= 'WHERE ' . $this->where_clause;
		$select = 'SELECT ' . implode( ', ', $this->columns_to_select ) . $from;

		if ( ! empty( $this->group_by ) ) {
			$select .= 'GROUP BY ' . implode( ', ', $this->group_by ) . ' ';
		}

		if ( $this->order_by !== '' ) {
			$select .= 'ORDER BY ' . $this->order_by . ' ';
		}

		$select .= 'LIMIT ' . $this->limit;

		if ( $this->offset !== '' ) {
			$select .= ' OFFSET ' . $this->offset;
		}

		return $select;
	}
public function get_sql ( ) : string { if ( empty ( $ this -> columns_to_select ) ) { // this should be the default behavior $ this -> columns_to_select = [ '*' ] ; } $ from = ' FROM ' . implode ( ', ' , $ this -> from ) . ' ' ; if ( ! empty ( $ this -> joins ) ) { $ from .= $ this -> joins ; } $ from .= 'WHERE ' . $ this -> where_clause ; $ select = 'SELECT ' . implode ( ', ' , $ this -> columns_to_select ) . $ from ; if ( ! empty ( $ this -> group_by ) ) { $ select .= 'GROUP BY ' . implode ( ', ' , $ this -> group_by ) . ' ' ; } if ( $ this -> order_by !== '' ) { $ select .= 'ORDER BY ' . $ this -> order_by . ' ' ; } $ select .= 'LIMIT ' . $ this -> limit ; if ( $ this -> offset !== '' ) { $ select .= ' OFFSET ' . $ this -> offset ; } return $ select ; }
Uses the current state of the object to build the sql statement

@return string : the sql select statement as a string
Uses the current state of the object to build the sql statement