protected function buildSelectQuery($table, $where = array(), $fields = '*', $order = array(), $limit = 0) {
        if(is_array($fields)) {
            $selectfields = array();
            foreach($fields as $field => $value) {
                $selectfields[] = sprintf("`%s`", SafeString::makeSafe($value));
            }
            $fieldList = implode(', ', $selectfields);
        }
        else{$fieldList = '*';}
        
        $this->sql = sprintf("SELECT %s FROM `%s`%s%s%s;", $fieldList, SafeString::makeSafe($table), $this->where($where), $this->orderBy($order), $this->limit($limit));
        $this->key = md5($this->database.$this->sql.serialize($this->values));
    }
protected function buildSelectQuery($table, $where = array(), $fields = '*', $order = array(), $limit = 0) {
        if(is_array($fields)) {
            $selectfields = array();
            foreach($fields as $field => $value) {
                $selectfields[] = sprintf("`%s`", SafeString::makeSafe($value));
            }
            $fieldList = implode(', ', $selectfields);
        }
        else{$fieldList = '*';}
        
        $this->sql = sprintf("SELECT %s FROM `%s`%s%s%s;", $fieldList, SafeString::makeSafe($table), $this->where($where), $this->orderBy($order), $this->limit($limit));
        $this->key = md5($this->database.$this->sql.serialize($this->values));
    }
protected function buildSelectQuery ( $ table , $ where = array ( ) , $ fields = '*' , $ order = array ( ) , $ limit = 0 ) { if ( is_array ( $ fields ) ) { $ selectfields = array ( ) ; foreach ( $ fields as $ field => $ value ) { $ selectfields [ ] = sprintf ( "`%s`" , SafeString :: makeSafe ( $ value ) ) ; } $ fieldList = implode ( ', ' , $ selectfields ) ; } else { $ fieldList = '*' ; } $ this -> sql = sprintf ( "SELECT %s FROM `%s`%s%s%s;" , $ fieldList , SafeString :: makeSafe ( $ table ) , $ this -> where ( $ where ) , $ this -> orderBy ( $ order ) , $ this -> limit ( $ limit ) ) ; $ this -> key = md5 ( $ this -> database . $ this -> sql . serialize ( $ this -> values ) ) ; }
Build the SQL query but doesn't execute it
@param string $table This should be the table you wish to select the values from
@param array $where Should be the field names and values you wish to use as the where query e.g. array('fieldname' => 'value', 'fieldname2' => 'value2', etc).
@param string|array $fields This should be the records you wis to select from the table. It should be either set as '*' which is the default or set as an array in the following format array('field', 'field2', 'field3', etc).
@param array $order This is the order you wish the results to be ordered in should be formatted as follows array('fieldname' => 'ASC') or array("'fieldname', 'fieldname2'" => 'DESC') so it can be done in both directions
@param integer|array $limit The number of results you want to return 0 is default and returns all results, else should be formated either as a standard integer or as an array as the start and end values e.g. array(0 => 150)
Build the SQL query but doesn t execute it