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);
 }
예제 #2
0
 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;
 }
예제 #3
0
<?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);
예제 #4
0
<?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.";
}
예제 #5
0
파일: Record.php 프로젝트: saltybeagle/DB
 /**
  * Get the DB
  * 
  * @return mysqli
  */
 public static function getDB()
 {
     return Connection::getDB();
 }
예제 #6
0
 public static function escapeString($string)
 {
     $mysqli = Connection::getDB();
     return $mysqli->escape_string($string);
 }