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


PHP Connection::getDB方法代碼示例

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


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

示例1: pagarCursoAction

 public function pagarCursoAction($params)
 {
     $resultado = array('code' => 404, 'message' => 'recurso no encontrado');
     $user_id = strip_tags(htmlspecialchars($params['user']));
     $user_id = intval($user_id);
     $user_id = filter_var($user_id, FILTER_VALIDATE_INT);
     $curso_id = strip_tags(htmlspecialchars($params['curso']));
     $curso_id = intval($curso_id);
     $curso_id = filter_var($curso_id, FILTER_VALIDATE_INT);
     if (!$user_id || !$curso_id) {
         $resultado['message'] = 'valores invalidos';
     } else {
         $DB = Connection::getDB();
         $result = $DB::table('perfil')->join('curso_perfil', 'perfil.perfil_id', '=', 'curso_perfil.perfil_id')->join('curso', 'curso_perfil.curso_id', '=', 'curso.curso_id')->select('perfil.perfil_id', 'perfil.username', 'perfil.email', 'curso.nombre')->where('curso_perfil.perfil_id', '=', $user_id)->where('curso_perfil.curso_id', '=', $curso_id)->get();
         if (count($result) == 0) {
             $resultado['message'] = 'usuario y curso no coinciden XD';
         } else {
             $value = $DB::table('curso_perfil')->where('curso_id', '=', $curso_id)->where('perfil_id', '=', $user_id)->update(array('payed' => 1));
             if ($value) {
                 $resultado['code'] = 200;
                 $resultado['message'] = 'se actualizo correctamente';
                 $resultado['curso_perfil'] = $result[0];
             } else {
                 $resultado['message'] = 'no se pudo actualizar XD';
             }
         }
     }
     return json_encode($resultado);
 }
開發者ID:CodeSomethingMX,項目名稱:barney,代碼行數:29,代碼來源:EscolaresController.class.php

示例2: getList

 public function getList()
 {
     $db = Connection::getDB();
     $guests = array();
     foreach ($db->guests() as $guest) {
         $guests[] = array('id' => $guest['id'], 'name' => $guest['name'], 'email' => $guest['email']);
     }
     return $guests;
 }
開發者ID:AndersonJosedaSilva,項目名稱:projeto2,代碼行數:9,代碼來源:CRUDService.php

示例3: json_encode

<?php

require 'connection.php';
$i = 0;
$db = Connection::getDB();
$list = array();
foreach ($db->pessoa() as $p) {
    $list[] = array('id' => utf8_encode($p['id']), 'genero' => utf8_encode($p['genero']), 'nome' => utf8_encode($p['nome']), 'cnpj' => utf8_encode($p['cnpj']), 'email' => utf8_encode($p['email_principal']));
}
echo json_encode($list);
開發者ID:andreluiz93,項目名稱:testeApp,代碼行數:10,代碼來源:test.php

示例4: Connection

<?php

include "db-con.php";
$con = new Connection();
// header('Content-Type: application/json');
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$categoryName = $request->categoryName;
$query = "select COUNT(CATG_NAME) from   categories where CATG_NAME=:category";
$pdo = $con->getDB();
$statement = $pdo->prepare($query);
$statement->bindParam(':category', $categoryName);
$statement->execute();
$count = $statement->fetchAll();
$tCount = $count[0]['COUNT(CATG_NAME)'];
if ($tCount == 0) {
    $veticalId = isset($request->parentCategory->CATG_ID) ? $request->parentCategory->CATG_ID : 0;
    $query = "insert into  categories(CATG_NAME,CATG_VERTICAL_ID)values(:category,{$veticalId})";
    //$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $pdo = $con->getDB();
    $statement = $pdo->prepare($query);
    $statement->bindParam(':category', $categoryName);
    if ($statement->execute()) {
        echo "success";
    } else {
        echo "error";
    }
} else {
    echo "Category already exists.";
}
開發者ID:rajusarvasiddi,項目名稱:spa-angularjs,代碼行數:30,代碼來源:process.php

示例5: getDB

 /**
  * Get the DB
  * 
  * @return mysqli
  */
 public static function getDB()
 {
     return Connection::getDB();
 }
開發者ID:saltybeagle,項目名稱:DB,代碼行數:9,代碼來源:Record.php

示例6: escapeString

 public static function escapeString($string)
 {
     $mysqli = Connection::getDB();
     return $mysqli->escape_string($string);
 }
開發者ID:saltybeagle,項目名稱:DB,代碼行數:5,代碼來源:RecordList.php


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