PHP 클래스 Longman\TelegramBot\DB

파일 보기 프로젝트 열기: akalongman/php-telegram-bot 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$mysql_credentials array MySQL credentials
$pdo PD\PDO PDO object
$table_prefix string Table prefix
$telegram Telegram Telegram class object

공개 메소드들

메소드 설명
entitiesArrayToJson ( array | null $entities, mixed $default = null ) : mixed Convert array of Entity items to a JSON array
externalInitialize ( PD\PDO $external_pdo_connection, Telegram $telegram, string $table_prefix = null ) : PD\PDO External Initialize
initialize ( array $credentials, Telegram $telegram, string $table_prefix = null, string $encoding = 'utf8mb4' ) : PD\PDO Initialize
insertCallbackQueryRequest ( CallbackQuery $callback_query ) : boolean Insert callback query request into database
insertChat ( Chat $chat, string $date, integer $migrate_to_chat_id = null ) : boolean Insert chat
insertChosenInlineResultRequest ( ChosenInlineResult $chosen_inline_result ) : boolean Insert chosen inline result request into database
insertEditedMessageRequest ( Message $edited_message ) : boolean Insert Edited Message request in db
insertInlineQueryRequest ( InlineQuery $inline_query ) : boolean Insert inline query request into database
insertMessageRequest ( Message $message ) : boolean Insert Message request in db
insertRequest ( Update $update ) : boolean Insert request into database
insertTelegramUpdate ( integer $id, integer $chat_id, integer $message_id, integer $inline_query_id, integer $chosen_inline_result_id, integer $callback_query_id, integer $edited_message_id ) : boolean Insert entry to telegram_update table
insertUser ( Longman\TelegramBot\Entities\User $user, string $date, Chat $chat = null ) : boolean Insert users and save their connection to chats
isDbConnected ( ) : boolean Check if database connection has been created
selectChats ( boolean $select_groups = true, boolean $select_super_groups = true, boolean $select_users = true, string $date_from = null, string $date_to = null, integer $chat_id = null, string $text = null ) : array | boolean Select Group and/or single Chats
selectMessages ( integer $limit = null ) : array | boolean Fetch message(s) from DB
selectTelegramUpdate ( integer $limit = null ) : array | boolean Fetch update(s) from DB

보호된 메소드들

메소드 설명
defineTables ( ) Define all the tables with the proper prefix
getTimestamp ( integer $time = null ) : string Convert from unix timestamp to timestamp

메소드 상세

defineTables() 보호된 정적인 메소드

Define all the tables with the proper prefix
protected static defineTables ( )

entitiesArrayToJson() 공개 정적인 메소드

Convert array of Entity items to a JSON array
public static entitiesArrayToJson ( array | null $entities, mixed $default = null ) : mixed
$entities array | null
$default mixed
리턴 mixed

externalInitialize() 공개 정적인 메소드

Let you use the class with an external already existing Pdo Mysql connection.
public static externalInitialize ( PD\PDO $external_pdo_connection, Telegram $telegram, string $table_prefix = null ) : PD\PDO
$external_pdo_connection PD\PDO PDO database object
$telegram Telegram Telegram object to connect with this object
$table_prefix string Table prefix
리턴 PD\PDO PDO database object

getTimestamp() 보호된 정적인 메소드

Convert from unix timestamp to timestamp
protected static getTimestamp ( integer $time = null ) : string
$time integer Unix timestamp (if null, current timestamp is used)
리턴 string

initialize() 공개 정적인 메소드

Initialize
public static initialize ( array $credentials, Telegram $telegram, string $table_prefix = null, string $encoding = 'utf8mb4' ) : PD\PDO
$credentials array Database connection details
$telegram Telegram Telegram object to connect with this object
$table_prefix string Table prefix
$encoding string Database character encoding
리턴 PD\PDO PDO database object

insertCallbackQueryRequest() 공개 정적인 메소드

Insert callback query request into database
public static insertCallbackQueryRequest ( CallbackQuery $callback_query ) : boolean
$callback_query Longman\TelegramBot\Entities\CallbackQuery
리턴 boolean If the insert was successful

insertChat() 공개 정적인 메소드

Insert chat
public static insertChat ( Chat $chat, string $date, integer $migrate_to_chat_id = null ) : boolean
$chat Longman\TelegramBot\Entities\Chat
$date string
$migrate_to_chat_id integer
리턴 boolean If the insert was successful

insertChosenInlineResultRequest() 공개 정적인 메소드

Insert chosen inline result request into database
public static insertChosenInlineResultRequest ( ChosenInlineResult $chosen_inline_result ) : boolean
$chosen_inline_result Longman\TelegramBot\Entities\ChosenInlineResult
리턴 boolean If the insert was successful

insertEditedMessageRequest() 공개 정적인 메소드

Insert Edited Message request in db
public static insertEditedMessageRequest ( Message $edited_message ) : boolean
$edited_message Longman\TelegramBot\Entities\Message
리턴 boolean If the insert was successful

insertInlineQueryRequest() 공개 정적인 메소드

Insert inline query request into database
public static insertInlineQueryRequest ( InlineQuery $inline_query ) : boolean
$inline_query Longman\TelegramBot\Entities\InlineQuery
리턴 boolean If the insert was successful

insertMessageRequest() 공개 정적인 메소드

Insert Message request in db
public static insertMessageRequest ( Message $message ) : boolean
$message Longman\TelegramBot\Entities\Message
리턴 boolean If the insert was successful

insertRequest() 공개 정적인 메소드

Insert request into database
public static insertRequest ( Update $update ) : boolean
$update Longman\TelegramBot\Entities\Update
리턴 boolean

insertTelegramUpdate() 공개 정적인 메소드

Insert entry to telegram_update table
public static insertTelegramUpdate ( integer $id, integer $chat_id, integer $message_id, integer $inline_query_id, integer $chosen_inline_result_id, integer $callback_query_id, integer $edited_message_id ) : boolean
$id integer
$chat_id integer
$message_id integer
$inline_query_id integer
$chosen_inline_result_id integer
$callback_query_id integer
$edited_message_id integer
리턴 boolean If the insert was successful

insertUser() 공개 정적인 메소드

Insert users and save their connection to chats
public static insertUser ( Longman\TelegramBot\Entities\User $user, string $date, Chat $chat = null ) : boolean
$user Longman\TelegramBot\Entities\User
$date string
$chat Longman\TelegramBot\Entities\Chat
리턴 boolean If the insert was successful

isDbConnected() 공개 정적인 메소드

Check if database connection has been created
public static isDbConnected ( ) : boolean
리턴 boolean

selectChats() 공개 정적인 메소드

Select Group and/or single Chats
public static selectChats ( boolean $select_groups = true, boolean $select_super_groups = true, boolean $select_users = true, string $date_from = null, string $date_to = null, integer $chat_id = null, string $text = null ) : array | boolean
$select_groups boolean
$select_super_groups boolean
$select_users boolean
$date_from string
$date_to string
$chat_id integer
$text string
리턴 array | boolean (Selected chats or false if invalid arguments)

selectMessages() 공개 정적인 메소드

Fetch message(s) from DB
public static selectMessages ( integer $limit = null ) : array | boolean
$limit integer Limit the number of messages to fetch
리턴 array | boolean Fetched data or false if not connected

selectTelegramUpdate() 공개 정적인 메소드

Fetch update(s) from DB
public static selectTelegramUpdate ( integer $limit = null ) : array | boolean
$limit integer Limit the number of updates to fetch
리턴 array | boolean Fetched data or false if not connected

프로퍼티 상세

$mysql_credentials 보호되어 있는 정적으로 프로퍼티

MySQL credentials
protected static array $mysql_credentials
리턴 array

$pdo 보호되어 있는 정적으로 프로퍼티

PDO object
protected static PDO,PD $pdo
리턴 PD\PDO

$table_prefix 보호되어 있는 정적으로 프로퍼티

Table prefix
protected static string $table_prefix
리턴 string

$telegram 보호되어 있는 정적으로 프로퍼티

Telegram class object
protected static Telegram,Longman\TelegramBot $telegram
리턴 Telegram