//* //* Perform a select query on Table $table in the current DB. //* Returns each match as a hash of the field names in //* in $fields or all data if $fields is not an array. function Sql_Select_Hashes($where="",$fieldnames=array(),$orderby="",$postprocess=FALSE,$table="",$limit="",$offset="") { if (!$this->Sql_Table_Exists($table)) { return array(); } $this->LastSqlWhere= $this->Sql_Select_Hashes_Query ( $where, $fieldnames, $orderby, $table, $limit, $offset ); $result=$this->DB_Query_2Assoc_List($this->LastSqlWhere); if ($result && $postprocess && method_exists($this,"PostProcessItemList")) { $this->PostProcessItemList($result); } if (empty($result)) { $result=array(); } return $result; } //* //* Generates the SQL slect hashes query. //* function Sql_Select_Hashes_Query($where="",$fields=array(),$orderby="",$table="",$limit="",$offset="") { if (empty($table)) { $table=$this->SqlTableName(); } if (is_array($where)) { $where=$this->Hash2SqlWhere($where); } if (empty($fields) || $fields=="*") { $fieldnames=array(); } else { $fieldnames=$this->Sql_Table_Fields_Exists($fields,$table); if (!preg_grep('/^ID$/',$fieldnames)) { array_push($fieldnames,"ID"); } } $query= 'SELECT '. $this->Sql_Table_Column_Names_Qualify($fieldnames). ' FROM '. /* $dbstring. */ $this->Sql_Table_Name_Qualify_With_DB($table). ''; if (preg_match('/\S/',$where)) { $query.=' WHERE '.$where; } if (!empty($orderby)) { $query.= ' ORDER BY '. $this->Sql_Table_Column_Sort_Names_Qualify($orderby); } if (!empty($limit)) { $query.=' LIMIT '.$limit; } if (!empty($offset)) { $query.=' OFFSET '.$offset; } return $query; }