Longman\TelegramBot\Telegram::enableMySql PHP Méthode

enableMySql() public méthode

Initialize Database connection
public enableMySql ( array $credential, string $table_prefix = null, string $encoding = 'utf8mb4' ) : Telegram
$credential array
$table_prefix string
$encoding string
Résultat Telegram
    public function enableMySql(array $credential, $table_prefix = null, $encoding = 'utf8mb4')
    {
        $this->pdo = DB::initialize($credential, $this, $table_prefix, $encoding);
        ConversationDB::initializeConversation();
        $this->mysql_enabled = true;
        return $this;
    }

Usage Example

 /**
  * setUp
  */
 protected function setUp()
 {
     $credentials = ['host' => PHPUNIT_DB_HOST, 'database' => PHPUNIT_DB_NAME, 'user' => PHPUNIT_DB_USER, 'password' => PHPUNIT_DB_PASS];
     $this->telegram = new Telegram('apikey', 'testbot');
     $this->telegram->enableMySql($credentials);
     //Make sure we start with an empty DB for each test.
     TestHelpers::emptyDB($credentials);
 }