当前位置: 首页>>代码示例>>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;未经允许,请勿转载。