-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Module5 task1 #13
base: master
Are you sure you want to change the base?
Module5 task1 #13
Conversation
* @param array $config Настройки подключения | ||
* @return mysqli|bool Возваращемый тип данных | ||
*/ | ||
function dbConnect(array $config):mysqli|bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Передать в нее $config['db']
и тогда внутри можно будет использовать ключи
$config['host'], $config['user'], ...
functions/db.php
Outdated
echo "Подключения к базе данных установлено"; | ||
} | ||
|
||
mysqli_set_charset($con, "utf8"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 пробела отступ
functions/db.php
Outdated
} | ||
|
||
mysqli_set_charset($con, "utf8"); | ||
return $con; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
аналогично
functions/db.php
Outdated
return $con; | ||
} | ||
// Запрос на получение новых лотов | ||
function getNewLotsFromDb(mysqli $con) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpdoc и прописать тип возвращаемого значения в сигнатуре
|
||
if (!$result) { | ||
$error = mysqli_error($con); | ||
print("SQL Error: $error"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exit();
functions/db.php
Outdated
} | ||
|
||
// Запрос на получения всех категорий | ||
function getAllCategoriesFromDb(mysqli $con) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpdoc и типа возвращаемого
@@ -0,0 +1,39 @@ | |||
<?php | |||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перенести описание к той функции, для которой оно написано
|
||
|
||
/** | ||
*Форматирует время лота |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
пробелы после *
function is_date_valid(string $date) : bool { | ||
$format_to_check = 'Y-m-d'; | ||
$dateTimeObj = date_create_from_format($format_to_check, $date); | ||
function isDateValid(string $date) : bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
создать файл
./funtions/validators.php
перенести туда функцию и подключить его через require
@@ -29,7 +30,8 @@ function is_date_valid(string $date) : bool { | |||
* | |||
* @return mysqli_stmt Подготовленное выражение | |||
*/ | |||
function db_get_prepare_stmt($link, $sql, $data = []) { | |||
function dbGetPrepareStmt(mysqli $link, $sql, $data = []):mysqli_stmt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
пробел после :
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перенести в fuctions/db.php
@@ -96,7 +98,7 @@ function db_get_prepare_stmt($link, $sql, $data = []) { | |||
* | |||
* @return string Рассчитанная форма множественнго числа | |||
*/ | |||
function get_noun_plural_form (int $number, string $one, string $two, string $many): string | |||
function getNounPluralForm (int $number, string $one, string $two, string $many): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перенести в functions/template.php
@@ -126,7 +128,8 @@ function get_noun_plural_form (int $number, string $one, string $two, string $ma | |||
* @param array $data Ассоциативный массив с данными для шаблона | |||
* @return string Итоговый HTML | |||
*/ | |||
function include_template($name, array $data = []) { | |||
function includeTemplate($name, array $data = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перенести в functions/template.php
* @param int|float $price | ||
* @return string | ||
*/ | ||
function formatAmount(int|float $price): string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
перенести в functions/template.php
*@param string $data | ||
*@return array | ||
*/ | ||
function remainingTime(string $date): array |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
можно тоже в перенести в functions/template.php
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code review
No description provided.