Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function sqlDelete($id)
- {
- $sql = "DELETE FROM " . $this->getTableName();
- $where1 = " WHERE";
- $countWhereRows = 1;
- $where2 = "";
- //Check welke Rows moeten worden verwijdered
- foreach ($id as $key => $value) {
- if ($countWhereRows == 0) {
- $where2 .= " " . $value;
- $countWhereRows++;
- } else {
- $where2 .= " " . $key . " = :" . $key;
- $countWhereRows -= 1;
- }
- }
- //Hier worden de WhereValues toegevoegd aan de Sql Query
- $sql = $sql . " " . $where1 . " " . $where2;
- if (!empty($limit)) {
- $sql .= " LIMIT " . $limit;
- }
- $stmt = $this->conn->prepare($sql);
- $bindCount = 0;
- //Binde de Gegevens aan de SQL Query
- foreach ($id as $key => $value) {
- if ($bindCount == 0) {
- $stmt->bindValue(':' . $key, $value);
- $bindCount++;
- } else {
- $bindCount -= 1;
- }
- }
- $this->resetSetAndGet();
- return $stmt->execute();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement