For any TIMESTAMP or DATETIME column in a table, you can assign the current timestamp as the default value, the auto-update value, or both:
- An auto-initialized column is set to the current timestamp for inserted rows that specify no value for the column.
- An auto-updated column is automatically updated to the current timestamp when the value of any other column in the row is changed from its current value. An auto-updated column remains unchanged if all other columns are set to their current values. To prevent an auto-updated column from updating when other columns change, explicitly set it to its current value. To update an auto-updated column even when other columns do not change, explicitly set it to the value it should have (for example, set it to CURRENT_TIMESTAMP).
не могу создать новую базу в идее, создается схемаНаоборот.
CREATE SCHEMA is a synonym for CREATE DATABASEhttps://dev.mysql.com/doc/refman/8.0/en/create-dat...
Будет ли этот запрос быстрее работать, если для столбца `time` есть индекс?Это покажет EXPLAIN, а ещё лучше - само выполнение запроса с индексом и без него. Скорее всего - будет.
Вообще насколько целесообразно делать индексы на все столбцы, которые есть в условии выборки и в которых много уникальных значений?В этом и заключается смысл индексации.
Сейчас при дублировании логина, идёт просто переход не срабатывает условие.
$sql = 'SELECT count(id) as count FROM users WHERE username=?';
...
echo "<script>alert('Логин уже занят')</script>";
...
if ($conn->query($sql) === true) {
header("Location: /");
}
=== true
. Но, думаю, просто у вас в коде где-то ещё какая-то подобная ерунда написана. Возвращает true в случае успешного выполнения или false в случае возникновения ошибки.https://www.php.net/manual/ru/pdostatement.execute.php
DB_HOST=mysql
DB_PORT=3306
Выполнил php artisan migrate и таблицы создались.Прекращайте выполнять команды на хосте - вся работа должна вестись в контейнерах, иначе смысла их использовать нет.
$emails = $data->groupBy('email')->pluck('email');