Привет, ребята, я пишу вам, потому что я реализовал разговор в своей бот-телеграмме, разработанной с Botman, но, к сожалению, я не могу сохранить данные объекта, созданного в моем mysql дБ. В журнале Laravel проверьте ошибку «local.ERROR: SQLSTATE [HY000] [2002] Превышено время ожидания соединения (SQL: вставить в ...», но если я попытаюсь выполнить команду «php artisan migrate: fre sh "Я могу правильно заполнить БД и затем соединиться с ней. ...
class StoryNW extends Conversation
{
/**
* Start the conversation.
*
* @return mixed
*/
protected $firstname;
protected $email;
public $user;
protected $userbot;
protected $checkUserDB;
protected $attachment;
public function run()
{
$this->i_01();
}
public function stopsConversation(IncomingMessage $message)
{
if ($message->getText() == 'stop') {
return true;
}
return false;
}
public function skipsConversation(IncomingMessage $message)
{
if ($message->getText() == 'pause') {
return true;
}
return false;
}
/** I_01 **/
public function i_01()
{
$this->say('start conversation');
UserBot::create([
'name' => $this->bot->getUser()->getFirstName().' '.$this->bot->getUser()->getLastName(),
'email' => 'pippo@yahoo.it',
'username' => $this->bot->getUser()->getUsername(),
'chat_id' => $this->bot->getUser()->getId()
]);*/
$this->say('user saved');
}
}
ERRO LOG:
SQLSTATE[HY000][2002] Connection timed out (SQL: insert into user_bots (name, email, username, chat_id, updated_at, created_at) values (Gianfri, pippo2@yahoo.it, ganfritolt, 18261059, ...)){"exception":"[object] (Illuminate\\Database\\QueryException(code: 2002): SQLSTATE[HY000] [2002] Connection timed out (SQL: insert into user_bots (name, email, username, chat_id, updated_at, created_at) values (Gianfri, pippo2@yahoo.it, ganfritolt, 18261059, ...)) at .../Database/Connection.php:664,PDOException(code: 2002): SQLSTATE[HY000] [2002] Connection timed out
/* My config/database.php */
'connections' => [
'sqlite' => [
'driver' => 'sqlite',
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '',
],
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
'pgsql' => [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
'schema' => 'public',
'sslmode' => 'prefer',
],
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
],
],
/* .env */
APP_NAME=Laravel
APP_ENV=local
APP_KEY=mykey
APP_DEBUG=true
APP_URL=http://localhost
LOG_CHANNEL=stack
TELEGRAM_TOKEN=tokenbot
DB_CONNECTION=mysql
DB_HOST=ipserver
DB_PORT=3306
DB_DATABASE=namemydb
DB_USERNAME=myusername
DB_PASSWORD=mypassword
...
TYPE DB: MySQL 10.1.44-MariaDB