Beispiel #1
0
         $_SESSION['msg'] = "Sua inserção falhou!";
         header('Location:../views/projects.php');
     }
     break;
 case 'update':
     if ($_POST['address'] != '' && $_POST['title'] != '') {
         if ($_FILES['image']['tmp_name'] != '') {
             if (is_uploaded_file($_FILES['image']['tmp_name'])) {
                 $_POST['image'] = resizer($_FILES['image']);
             }
         } else {
             $_POST['image'] = Projects::selectImage($_POST['id'], $connect);
         }
         $projects = new Projects($_POST);
         try {
             $projects->update($_POST['id'], $connect);
             $_SESSION['msg'] = "Sua edição foi realizada com sucesso!";
             header('Location:../views/projects.php');
         } catch (PDOException $e) {
             $_SESSION['msg'] = "Sua edição falhou!";
             header('Location:../views/projects.php');
         }
     }
     break;
 case 'delete':
     if (isset($_POST['id'])) {
         if (Projects::delete($_POST['id'], $connect)) {
             $_SESSION['msg'] = "Serviço deletado.";
             header('Location:../views/projects.php');
         }
     } else {
<?php

ini_set('date.timezone', 'America/Los_Angeles');
include 'config.php';
// need to set the database type for PDO factory
$ConfigArray['DBDSN']['phptype'] = 'mysql';
//include 'A/Db/Pdo.php';
include 'A/Db/Tabledatagateway.php';
class Projects extends A_Db_Tabledatagateway
{
}
$db = new A_Db_Pdo($ConfigArray['DBDSN']);
$db->connect();
if ($db->isError()) {
    die('ERROR: ' . $db->getMessage());
}
$project = new Projects($db, 'users');
$rows = $project->find(1);
dump($project->sql);
dump($rows);
// Get the current row
dump($rows->current());
// Get all rows
$all = $rows->fetchAll();
dump($all);
// Update some data
$data = array('lastname' => 'testert');
$updated = $project->update($data, 'id = 1');
//dump($updated);
$rows = $project->find(1);
dump($rows->current());