当前位置: 首页>>代码示例>>PHP>>正文


PHP ConnectionFactory::getDB方法代码示例

本文整理汇总了PHP中ConnectionFactory::getDB方法的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionFactory::getDB方法的具体用法?PHP ConnectionFactory::getDB怎么用?PHP ConnectionFactory::getDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConnectionFactory的用法示例。


在下文中一共展示了ConnectionFactory::getDB方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: listTasks

 public static function listTasks()
 {
     $db = ConnectionFactory::getDB();
     $tasks = array();
     foreach ($db->tasks() as $task) {
         //vai para o banco de dados dentro da tabela tasks
         $tasks[] = array('id' => $task['id'], 'description' => $task['description'], 'done' => $task['done']);
     }
 }
开发者ID:EltonCustodio,项目名称:php-todolist,代码行数:9,代码来源:TaskService.php

示例2: delete

 public static function delete($id)
 {
     $db = ConnectionFactory::getDB();
     $task = $db->tasks[$id];
     if ($task) {
         $task->delete();
         return true;
     }
     return false;
 }
开发者ID:ricardo-faria,项目名称:php-todolist,代码行数:10,代码来源:TaskService.php

示例3: delete

 public static function delete($id)
 {
     $db = ConnectionFactory::getDB();
     $guest = $db->guests[$id];
     if ($guest) {
         $guest->delete();
         return true;
     }
     return false;
 }
开发者ID:alfredudu,项目名称:alfredudu-guest-list-exam,代码行数:10,代码来源:GuestService.php

示例4: delete

 public static function delete($id)
 {
     $db = ConnectionFactory::getDB();
     $cart = $db->carts[$id];
     if ($cart) {
         $cart->delete();
         return true;
     }
     return false;
 }
开发者ID:andressafaria,项目名称:shopping-cart-exam,代码行数:10,代码来源:CartService.php

示例5: delete

 public static function delete($id)
 {
     $db = ConnectionFactory::getDB();
     $item = $db->items[$id];
     if ($item) {
         $item->delete();
         return true;
     }
     return false;
 }
开发者ID:flavionasc,项目名称:shoping-cart-exam,代码行数:10,代码来源:CartService.php

示例6: update

 public static function update($updatedGuest)
 {
     $db = ConnectionFactory::getDB();
     $guest = $db->guests[$updatedGuest['id']];
     if ($guest) {
         $guest['nome'] = $updatedGuest['nome'];
         $guest['email'] = $updatedGuest['email'];
         return true;
     }
     return false;
 }
开发者ID:EltonCustodio,项目名称:guest-list-exam,代码行数:11,代码来源:service.php

示例7: listTasks

 public static function listTasks()
 {
     $db = ConnectionFactory::getDB();
     //Classe que pega a conexão com o Banco de Dados
     $tasks = array();
     //$tasks = uma caixa, 'vetor', vazio
     foreach ($db->tasks() as $task) {
         //O tasks (depois do '$db->') é o nome da TABELA em schema.sql | Para cada registro da tabela, colocar dentro do $tasks (vetor)
         $tasks[] = array('id' => $task['id'], 'description' => $task['description'], 'done' => $task['done']);
     }
     $tasks;
 }
开发者ID:juliocezah,项目名称:php-todolist,代码行数:12,代码来源:TaskService.php

示例8: function

$app = new \Slim\Slim();
$app->get('/guest', function () use($app) {
    $db = ConnectionFactory::getDB();
    $guests = array();
    foreach ($db->guests() as $guests) {
        $guests[] = array('id' => $guest["id"], 'name' => $guest['name'], 'email' => $guest['email']);
    }
    $app->response()->header('Content-Type', 'application/json');
    echo json_encode($guests);
});
$app->post('/guest', function () use($app) {
    $db = ConnectionFactory::getDB();
    $guestToAdd = json_decode($app->request->getBody(), true);
    $guest = $db->guests->insert($guestToAdd);
    $app->response->header('Content-Type', 'application/json');
    echo json_encode($guest);
});
$app->delete('/guest/:nome', function ($nome) use($app) {
    $db = ConnectionFactory::getDB();
    $response = "";
    $guest = $db->guests()->where('nome', $nome);
    if ($guest->fetch()) {
        $result = $guest->delete();
        $response = array('status' => 'true', 'message' => 'Guest deleted!');
    } else {
        $response = array('status' => 'false', 'message' => 'Guest with $id does not exit');
        $app->response->setStatus(404);
    }
    $app->response()->header('Content-Type', 'application/json');
    echo json_encode($response);
});
开发者ID:EltonCustodio,项目名称:guest-list-exam,代码行数:31,代码来源:index.php


注:本文中的ConnectionFactory::getDB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。