changes
This commit is contained in:
+2
-2
@@ -82,7 +82,7 @@ class Book {
|
||||
try {
|
||||
$this->pdo->beginTransaction();
|
||||
|
||||
// Удаляем главы книги (сработает CASCADE, но лучше явно)
|
||||
// Удаляем главы книги
|
||||
$stmt = $this->pdo->prepare("DELETE FROM chapters WHERE book_id = ?");
|
||||
$stmt->execute([$id]);
|
||||
|
||||
@@ -127,7 +127,7 @@ class Book {
|
||||
}
|
||||
|
||||
public function deleteCover($book_id) {
|
||||
// Сначала получаем текущее имя файла
|
||||
|
||||
$book = $this->findById($book_id);
|
||||
$old_filename = $book['cover_image'];
|
||||
|
||||
|
||||
@@ -30,13 +30,11 @@ class Chapter {
|
||||
}
|
||||
|
||||
public function create($data) {
|
||||
// Сначала получаем максимальный sort_order для этой книги
|
||||
$stmt = $this->pdo->prepare("SELECT MAX(sort_order) as max_order FROM chapters WHERE book_id = ?");
|
||||
$stmt->execute([$data['book_id']]);
|
||||
$result = $stmt->fetch();
|
||||
$next_order = ($result['max_order'] ?? 0) + 1;
|
||||
|
||||
// Подсчитываем количество слов
|
||||
$word_count = $this->countWords($data['content']);
|
||||
|
||||
$stmt = $this->pdo->prepare("
|
||||
@@ -81,7 +79,6 @@ class Chapter {
|
||||
}
|
||||
|
||||
private function countWords($text) {
|
||||
// Простой подсчет слов (можно улучшить)
|
||||
$text = strip_tags($text);
|
||||
$text = preg_replace('/[^\p{L}\p{N}\s]/u', ' ', $text);
|
||||
$words = preg_split('/\s+/', $text);
|
||||
|
||||
@@ -85,11 +85,9 @@ class Series {
|
||||
try {
|
||||
$this->pdo->beginTransaction();
|
||||
|
||||
// Убираем серию у всех книг
|
||||
$stmt = $this->pdo->prepare("UPDATE books SET series_id = NULL, sort_order_in_series = NULL WHERE series_id = ? AND user_id = ?");
|
||||
$stmt->execute([$id, $user_id]);
|
||||
|
||||
// Удаляем саму серию
|
||||
$stmt = $this->pdo->prepare("DELETE FROM series WHERE id = ? AND user_id = ?");
|
||||
$result = $stmt->execute([$id, $user_id]);
|
||||
|
||||
@@ -126,7 +124,6 @@ class Series {
|
||||
return ($result['max_order'] ?? 0) + 1;
|
||||
}
|
||||
|
||||
// Новый метод для получения статистики по серии
|
||||
public function getSeriesStats($series_id, $user_id = null) {
|
||||
$sql = "
|
||||
SELECT
|
||||
|
||||
@@ -35,7 +35,6 @@ class User {
|
||||
public function create($data) {
|
||||
$password_hash = password_hash($data['password'], PASSWORD_DEFAULT);
|
||||
|
||||
// Определяем статус активности: по умолчанию неактивен, если не указано иное
|
||||
$is_active = $data['is_active'] ?? 0;
|
||||
|
||||
$stmt = $this->pdo->prepare("
|
||||
|
||||
Reference in New Issue
Block a user