Inheritance: extends Entity
Ejemplo n.º 1
0
 /**
  * Insert chosen inline result request into database
  *
  * @param Entities\ChosenInlineResult &$chosen_inline_result
  *
  * @return bool If the insert was successful
  * @throws TelegramException
  */
 public static function insertChosenInlineResultRequest(ChosenInlineResult &$chosen_inline_result)
 {
     if (!self::isDbConnected()) {
         return false;
     }
     try {
         $mysql_query = 'INSERT INTO `' . TB_CHOSEN_INLINE_RESULT . '`
                 (
                 `result_id`, `user_id`, `location`, `inline_message_id`, `query`, `created_at`
                 )
                 VALUES (
                 :result_id, :user_id, :location, :inline_message_id, :query, :created_at
                 )';
         $sth_insert_chosen_inline_result = self::$pdo->prepare($mysql_query);
         $date = self::getTimestamp(time());
         $result_id = $chosen_inline_result->getResultId();
         $from = $chosen_inline_result->getFrom();
         $user_id = null;
         if (is_object($from)) {
             $user_id = $from->getId();
             self::insertUser($from, $date);
         }
         $location = $chosen_inline_result->getLocation();
         $inline_message_id = $chosen_inline_result->getInlineMessageId();
         $query = $chosen_inline_result->getQuery();
         $sth_insert_chosen_inline_result->bindParam(':result_id', $result_id, \PDO::PARAM_STR);
         $sth_insert_chosen_inline_result->bindParam(':user_id', $user_id, \PDO::PARAM_INT);
         $sth_insert_chosen_inline_result->bindParam(':location', $location, \PDO::PARAM_INT);
         $sth_insert_chosen_inline_result->bindParam(':inline_message_id', $inline_message_id, \PDO::PARAM_STR);
         $sth_insert_chosen_inline_result->bindParam(':query', $query, \PDO::PARAM_STR);
         $sth_insert_chosen_inline_result->bindParam(':created_at', $date, \PDO::PARAM_STR);
         return $sth_insert_chosen_inline_result->execute();
     } catch (\PDOException $e) {
         throw new TelegramException($e->getMessage());
     }
 }