本文整理汇总了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']);
}
}
示例2: delete
public static function delete($id)
{
$db = ConnectionFactory::getDB();
$task = $db->tasks[$id];
if ($task) {
$task->delete();
return true;
}
return false;
}
示例3: delete
public static function delete($id)
{
$db = ConnectionFactory::getDB();
$guest = $db->guests[$id];
if ($guest) {
$guest->delete();
return true;
}
return false;
}
示例4: delete
public static function delete($id)
{
$db = ConnectionFactory::getDB();
$cart = $db->carts[$id];
if ($cart) {
$cart->delete();
return true;
}
return false;
}
示例5: delete
public static function delete($id)
{
$db = ConnectionFactory::getDB();
$item = $db->items[$id];
if ($item) {
$item->delete();
return true;
}
return false;
}
示例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;
}
示例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;
}
示例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);
});