/** * Deletes a row from a table * @param string $tableName * @param array $search */ private function delete($tableName, $search) { $select = new eDB_Select(); $rowID = $select->getRowIdBySearch($search, $tableName); $content = $select->search($tableName, '*'); unset($content[$rowID - 1]); $cols = $select->getColumns($tableName); $completeContent[] = $cols; foreach ($content as $row) { $completeContent[] = $row; } $update = new eDB_Update(); $update->updateTable($completeContent, $tableName); }
/** * Sets a primary key which contains auto increement * * @param string $table * @param string $name * @param int $startpos */ public function setPrimaryKey($table, $name, $startpos = 1) { $select = new eDB_Select($table, '*'); $cols = $select->getColumns($table, true); if (!is_array($cols)) { return false; } if (preg_match("#{$name}:key;[0-9]#i", implode('|', $cols))) { return false; } $i = 0; foreach ($cols as $x) { if ($x == $name) { break; } ++$i; } if ($select->result) { foreach ($select->result as $key => $x) { $select->result[$key][$cols[$i]] = $startpos; ++$startpos; } } else { $select->result = array(); } $cols[$i] = $cols[$i] . ":key;{$startpos}"; $thecols[0] = $cols; $result = array_merge($thecols, $select->result); array_values($result); $update = new eDB_Update(); $update->updateTable($result, $table); }