diff --git a/BancaDati/BancaDati.php b/BancaDati/BancaDati.php index 50ab02b..eb0c5ab 100644 --- a/BancaDati/BancaDati.php +++ b/BancaDati/BancaDati.php @@ -100,16 +100,23 @@ class BancaDati { } } - - public function select(string $table, array $data, array $order = null){ - $where = ""; - foreach ($data as $col => $v) { - if($where != ""){ - $where .= " AND "; + /** + * einheitliche Select Funktion + * @param string $table + * @param array $where ["column"]=>"value" es wird mit LIKE verglichen und mit AND verbunden + * @param array|null $order ["by"]=>"column"; ["order"]=>"ASC|DESC" + * @return void + * @author Malte Schulze Hobeling + */ + public function select(string $table, array $where, array $order = null){ + $whereString = ""; + foreach ($where as $col => $v) { + if($whereString != ""){ + $whereString .= " AND "; } - $where .= $col . "=" . $v; + $whereString .= $col . " LIKE " . $v; } - $sql = "SELECT * FROM ".$table." WHERE ".$where; + $sql = "SELECT * FROM ".$table." WHERE ".$whereString; if(isset($order["by"])){ $sql .= " ORDER BY ".$order["by"]; }