@@ -164,6 +164,9 @@ public static function insertUser(User $user, $date, Chat $chat = null)
164
164
}
165
165
166
166
$ user_id = $ user ->getId ();
167
+ $ username = $ user ->getUsername ();
168
+ $ first_name = $ user ->getFirstName ();
169
+ $ last_name = $ user ->getLastName ();
167
170
168
171
try {
169
172
//Users table
@@ -179,9 +182,9 @@ public static function insertUser(User $user, $date, Chat $chat = null)
179
182
' );
180
183
181
184
$ sth1 ->bindParam (':id ' , $ user_id , \PDO ::PARAM_INT );
182
- $ sth1 ->bindParam (':username ' , $ user -> getUsername () , \PDO ::PARAM_STR , 255 );
183
- $ sth1 ->bindParam (':first_name ' , $ user -> getFirstName () , \PDO ::PARAM_STR , 255 );
184
- $ sth1 ->bindParam (':last_name ' , $ user -> getLastName () , \PDO ::PARAM_STR , 255 );
185
+ $ sth1 ->bindParam (':username ' , $ username , \PDO ::PARAM_STR , 255 );
186
+ $ sth1 ->bindParam (':first_name ' , $ first_name , \PDO ::PARAM_STR , 255 );
187
+ $ sth1 ->bindParam (':last_name ' , $ last_name , \PDO ::PARAM_STR , 255 );
185
188
$ sth1 ->bindParam (':date ' , $ date , \PDO ::PARAM_STR );
186
189
187
190
$ status = $ sth1 ->execute ();
@@ -192,6 +195,7 @@ public static function insertUser(User $user, $date, Chat $chat = null)
192
195
}
193
196
//insert also the relationship to the chat
194
197
if (!is_null ($ chat )) {
198
+ $ chat_id = $ chat ->getId ();
195
199
try {
196
200
//user_chat table
197
201
$ sth3 = self ::$ pdo ->prepare ('INSERT IGNORE INTO ` ' .TB_USERS_CHATS .'`
@@ -202,7 +206,7 @@ public static function insertUser(User $user, $date, Chat $chat = null)
202
206
' );
203
207
204
208
$ sth3 ->bindParam (':user_id ' , $ user_id , \PDO ::PARAM_INT );
205
- $ sth3 ->bindParam (':chat_id ' , $ chat -> getId () , \PDO ::PARAM_INT );
209
+ $ sth3 ->bindParam (':chat_id ' , $ chat_id , \PDO ::PARAM_INT );
206
210
207
211
$ status = $ sth3 ->execute ();
208
212
@@ -272,16 +276,14 @@ public static function insertRequest(Update $update)
272
276
try {
273
277
//chats table
274
278
$ sth2 = self ::$ pdo ->prepare ('INSERT INTO ` ' .TB_CHATS .'`
275
- (
276
- `id`, `title`, `created_at` ,`updated_at`
277
- )
279
+ (`id`, `title`, `created_at` ,`updated_at`)
278
280
VALUES (:id, :title, :date, :date)
279
- ON DUPLICATE KEY UPDATE `title`=:title, `updated_at`=:date
280
- ' );
281
+ ON DUPLICATE KEY UPDATE `title`=:title, `updated_at`=:date ' );
281
282
283
+ $ chat_title = $ chat ->getTitle ();
282
284
283
285
$ sth2 ->bindParam (':id ' , $ chat_id , \PDO ::PARAM_INT );
284
- $ sth2 ->bindParam (':title ' , $ chat-> getTitle () , \PDO ::PARAM_STR , 255 );
286
+ $ sth2 ->bindParam (':title ' , $ chat , \PDO ::PARAM_STR , 255 );
285
287
$ sth2 ->bindParam (':date ' , $ date , \PDO ::PARAM_STR );
286
288
287
289
$ status = $ sth2 ->execute ();
@@ -302,18 +304,35 @@ public static function insertRequest(Update $update)
302
304
:new_chat_title, :new_chat_photo, :delete_chat_photo, :group_chat_created
303
305
) ' );
304
306
305
-
306
- $ sth ->bindParam (':update_id ' , $ update ->getUpdateId (), \PDO ::PARAM_INT );
307
- $ sth ->bindParam (':message_id ' , $ message ->getMessageId (), \PDO ::PARAM_INT );
308
- $ sth ->bindParam (':user_id ' , $ from ->getId (), \PDO ::PARAM_INT );
307
+ $ update_id = $ update ->getUpdateId ();
308
+ $ message_id = $ message ->getMessageId ();
309
+ $ from_id = $ from ->getId ();
310
+ $ reply_to_message = $ message ->getReplyToMessage ();
311
+ $ text = $ message ->getText ();
312
+ $ audio = $ message ->getAudio ();
313
+ $ document = $ message ->getDocument ();
314
+ $ sticker = $ message ->getSticker ();
315
+ $ video = $ message ->getVideo ();
316
+ $ voice = $ message ->getVoice ();
317
+ $ caption = $ message ->getCaption ();
318
+ $ contanc = $ message ->getContact ();
319
+ $ location = $ message ->getLocation ();
320
+ $ new_chat_title = $ message ->getNewChatTitle ();
321
+ $ delete_chat_photo = $ message ->getDeleteChatPhoto ();
322
+ $ group_chat_created = $ message ->getGroupChatCreated ();
323
+
324
+
325
+ $ sth ->bindParam (':update_id ' , $ update_id , \PDO ::PARAM_INT );
326
+ $ sth ->bindParam (':message_id ' , $ message_id , \PDO ::PARAM_INT );
327
+ $ sth ->bindParam (':user_id ' , $ from_id , \PDO ::PARAM_INT );
309
328
$ sth ->bindParam (':date ' , $ date , \PDO ::PARAM_STR );
310
329
$ sth ->bindParam (':chat_id ' , $ chat_id , \PDO ::PARAM_STR );
311
330
$ sth ->bindParam (':forward_from ' , $ forward_from , \PDO ::PARAM_STR );
312
331
$ sth ->bindParam (':forward_date ' , $ forward_date , \PDO ::PARAM_STR );
313
- $ sth ->bindParam (':reply_to_message ' , $ message -> getReplyToMessage () , \PDO ::PARAM_STR );
314
- $ sth ->bindParam (':text ' , $ message -> getText () , \PDO ::PARAM_STR );
315
- $ sth ->bindParam (':audio ' , $ message -> getAudio () , \PDO ::PARAM_STR );
316
- $ sth ->bindParam (':document ' , $ message -> getDocument () , \PDO ::PARAM_STR );
332
+ $ sth ->bindParam (':reply_to_message ' , $ reply_to_message , \PDO ::PARAM_STR );
333
+ $ sth ->bindParam (':text ' , $ text , \PDO ::PARAM_STR );
334
+ $ sth ->bindParam (':audio ' , $ audio , \PDO ::PARAM_STR );
335
+ $ sth ->bindParam (':document ' , $ document , \PDO ::PARAM_STR );
317
336
//Try with to magic shoud work
318
337
$ var = [];
319
338
if (is_array ($ photo )) {
@@ -327,15 +346,15 @@ public static function insertRequest(Update $update)
327
346
}
328
347
329
348
$ sth ->bindParam (':photo ' , $ photo , \PDO ::PARAM_STR );
330
- $ sth ->bindParam (':sticker ' , $ message -> getSticker () , \PDO ::PARAM_STR );
331
- $ sth ->bindParam (':video ' , $ message -> getVideo () , \PDO ::PARAM_STR );
332
- $ sth ->bindParam (':voice ' , $ message -> getVoice () , \PDO ::PARAM_STR );
333
- $ sth ->bindParam (':caption ' , $ message -> getCaption () , \PDO ::PARAM_STR );
334
- $ sth ->bindParam (':contact ' , $ message -> getContact () , \PDO ::PARAM_STR );
335
- $ sth ->bindParam (':location ' , $ message -> getLocation () , \PDO ::PARAM_STR );
349
+ $ sth ->bindParam (':sticker ' , $ sticker , \PDO ::PARAM_STR );
350
+ $ sth ->bindParam (':video ' , $ video , \PDO ::PARAM_STR );
351
+ $ sth ->bindParam (':voice ' , $ voice , \PDO ::PARAM_STR );
352
+ $ sth ->bindParam (':caption ' , $ caption , \PDO ::PARAM_STR );
353
+ $ sth ->bindParam (':contact ' , $ contanct , \PDO ::PARAM_STR );
354
+ $ sth ->bindParam (':location ' , $ location , \PDO ::PARAM_STR );
336
355
$ sth ->bindParam (':new_chat_participant ' , $ new_chat_paticipant , \PDO ::PARAM_STR );
337
356
$ sth ->bindParam (':left_chat_participant ' , $ left_chat_paticipant , \PDO ::PARAM_STR );
338
- $ sth ->bindParam (':new_chat_title ' , $ message -> getNewChatTitle () , \PDO ::PARAM_STR );
357
+ $ sth ->bindParam (':new_chat_title ' , $ new_chat_title , \PDO ::PARAM_STR );
339
358
//Array of Photosize
340
359
341
360
$ var = [];
@@ -350,8 +369,8 @@ public static function insertRequest(Update $update)
350
369
}
351
370
352
371
$ sth ->bindParam (':new_chat_photo ' , $ new_chat_photo , \PDO ::PARAM_STR );
353
- $ sth ->bindParam (':delete_chat_photo ' , $ message -> getDeleteChatPhoto () , \PDO ::PARAM_STR );
354
- $ sth ->bindParam (':group_chat_created ' , $ message -> getGroupChatCreated () , \PDO ::PARAM_STR );
372
+ $ sth ->bindParam (':delete_chat_photo ' , $ delete_chat_photo , \PDO ::PARAM_STR );
373
+ $ sth ->bindParam (':group_chat_created ' , $ group_chat_created , \PDO ::PARAM_STR );
355
374
356
375
$ status = $ sth ->execute ();
357
376
0 commit comments