Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
e9be41ef
Unverified
Commit
e9be41ef
authored
Aug 27, 2016
by
Armando Lüscher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Various little code and comment updates.
parent
f1909df0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
18 deletions
+19
-18
DB.php
src/DB.php
+19
-18
No files found.
src/DB.php
View file @
e9be41ef
...
...
@@ -105,9 +105,12 @@ class DB
* @return PDO PDO database object
* @throws \Longman\TelegramBot\Exception\TelegramException
*/
public
static
function
externalInitialize
(
$external_pdo_connection
,
Telegram
$telegram
,
$table_prefix
=
null
)
{
if
(
empty
(
$external_pdo_connection
))
{
public
static
function
externalInitialize
(
$external_pdo_connection
,
Telegram
$telegram
,
$table_prefix
=
null
)
{
if
(
$external_pdo_connection
===
null
)
{
throw
new
TelegramException
(
'MySQL external connection not provided!'
);
}
...
...
@@ -122,7 +125,7 @@ class DB
}
/**
* Define all the table with the proper prefix
* Define all the table
s
with the proper prefix
*/
protected
static
function
defineTables
()
{
...
...
@@ -152,11 +155,7 @@ class DB
*/
public
static
function
isDbConnected
()
{
if
(
empty
(
self
::
$pdo
))
{
return
false
;
}
else
{
return
true
;
}
return
self
::
$pdo
!==
null
;
}
/**
...
...
@@ -185,10 +184,10 @@ class DB
}
$sth
=
self
::
$pdo
->
prepare
(
$sql
);
$sth
->
bindParam
(
':limit'
,
$limit
,
\
PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':limit'
,
$limit
,
PDO
::
PARAM_INT
);
$sth
->
execute
();
return
$sth
->
fetchAll
(
\
PDO
::
FETCH_ASSOC
);
return
$sth
->
fetchAll
(
PDO
::
FETCH_ASSOC
);
}
catch
(
PDOException
$e
)
{
throw
new
TelegramException
(
$e
->
getMessage
());
}
...
...
@@ -249,6 +248,8 @@ class DB
/**
* Convert array of Entity items to a JSON array
*
* @todo Find a better way, as json_* functions are very heavy
*
* @param array $entities
* @param mixed $default
*
...
...
@@ -631,8 +632,8 @@ class DB
}
try
{
$sth
=
self
::
$pdo
->
prepare
(
'
INSERT IGNORE INTO `'
.
TB_CALLBACK_QUERY
.
'`
$sth
=
self
::
$pdo
->
prepare
(
'
INSERT IGNORE INTO `'
.
TB_CALLBACK_QUERY
.
'`
(`id`, `user_id`, `chat_id`, `message_id`, `inline_message_id`, `data`, `created_at`)
VALUES
(:callback_query_id, :user_id, :chat_id, :message_id, :inline_message_id, :data, :created_at)
...
...
@@ -736,11 +737,11 @@ class DB
}
//New and left chat member
if
(
$new_chat_member
)
{
if
(
$new_chat_member
instanceof
User
)
{
//Insert the new chat user
self
::
insertUser
(
$new_chat_member
,
$date
,
$chat
);
$new_chat_member
=
$new_chat_member
->
getId
();
}
elseif
(
$left_chat_member
)
{
}
elseif
(
$left_chat_member
instanceof
User
)
{
//Insert the left chat user
self
::
insertUser
(
$left_chat_member
,
$date
,
$chat
);
$left_chat_member
=
$left_chat_member
->
getId
();
...
...
@@ -807,12 +808,12 @@ class DB
$sth
->
bindParam
(
':forward_from_chat'
,
$forward_from_chat
,
PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':forward_date'
,
$forward_date
,
PDO
::
PARAM_STR
);
$reply_chat_id
=
null
;
$reply_
to_
chat_id
=
null
;
if
(
$reply_to_message_id
)
{
$reply_chat_id
=
$chat_id
;
$reply_
to_
chat_id
=
$chat_id
;
}
$sth
->
bindParam
(
':reply_to_chat'
,
$reply_chat_id
,
PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':reply_to_chat'
,
$reply_
to_
chat_id
,
PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':reply_to_message'
,
$reply_to_message_id
,
PDO
::
PARAM_INT
);
$sth
->
bindParam
(
':text'
,
$text
,
PDO
::
PARAM_STR
);
$sth
->
bindParam
(
':entities'
,
$entities
,
PDO
::
PARAM_STR
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment