當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Connect::connect方法代碼示例

本文整理匯總了PHP中Connect::connect方法的典型用法代碼示例。如果您正苦於以下問題:PHP Connect::connect方法的具體用法?PHP Connect::connect怎麽用?PHP Connect::connect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Connect的用法示例。


在下文中一共展示了Connect::connect方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sendGCMMessage

 public static function sendGCMMessage($title, $msg, $eventoId, $disciplina)
 {
     include "../webservice/connection/Connect.php";
     $db = new Connect();
     $connection = $db->connect();
     //$acao = $_POST['acao'];
     // if ($acao == "enviar") {
     $jsonArray = array();
     $sql = $connection->prepare("SELECT app_dispositivo.registration_id FROM henriqueweb.app_dispositivo");
     $sql->execute();
     if ($sql->rowCount() > 0) {
         while ($tmp = $sql->fetch()) {
             $jsonArray[] = $tmp["registration_id"];
         }
     }
     //$mensagem = $_POST["mensagem"];
     //$eventoId = $_POST["eventoId"];
     $url = "https://gcm-http.googleapis.com/gcm/send";
     $apiKey = "AIzaSyD4-EStQ8w7G8FP2plyIkIOJ10LljchUpw";
     $ch = curl_init($url);
     $jsonData = array("registration_ids" => $jsonArray, "data" => array("type" => "evento", "title" => $title, "disciplina" => $disciplina, "eventoId" => $eventoId, "mensagem" => $msg));
     $jsonDataEncoded = json_encode($jsonData);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: key=" . $apiKey));
     $result = curl_exec($ch);
     //}
 }
開發者ID:luizhsda10,項目名稱:UFMSApp,代碼行數:28,代碼來源:GCMHandler.php

示例2: json_encode

<?php

header('Content-Type: application/json; Charset=UTF-8');
include "../connection/Connect.php";
$db = new Connect();
$connection = $db->connect();
$sql = "UPDATE app_rating_disciplina SET app_rating = ? WHERE (app_aluno_key = ?) AND (app_disciplina_key = ?)";
$query = $connection->prepare($sql);
$disciplinaRating = $_POST['disciplinaRating'];
$alunoKey = $_POST['alunoKey'];
$disciplinaKey = $_POST['disciplinaKey'];
$query->execute(array($disciplinaRating, $alunoKey, $disciplinaKey));
$returnJson = array("updated" => $query->rowCount());
echo json_encode($returnJson);
開發者ID:luizhsda10,項目名稱:UFMSApp,代碼行數:14,代碼來源:updateRateDisciplina.php


注:本文中的Connect::connect方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。