コード例 #1
0
 /**
  * Executes the test
  */
 function execute()
 {
     $persistence = new Persistence("Object");
     $persistence->setProperty("ID", 1);
     assert($persistence->getSelectString() == "SELECT * FROM ##Object WHERE ID = 1");
     echo "Select string: " . $persistence->getSelectString();
 }
コード例 #2
0
 public static function getInstance()
 {
     if (self::$_instance == null) {
         self::$_instance = new Persistence();
     }
     return self::$_instance;
 }
コード例 #3
0
ファイル: lib.php プロジェクト: lursu/morgue
 static function perform($terms)
 {
     $terms = Search::split_terms($terms);
     $terms_db = Search::db_escape_terms($terms);
     $terms_rx = Search::rx_escape_terms($terms);
     $parts = array();
     foreach ($terms_db as $term_db) {
         array_push($parts, "(summary RLIKE '{$term_db}' OR title RLIKE '{$term_db}')");
     }
     $parts = implode(' AND ', $parts);
     $conn = Persistence::get_database_object();
     $sql = "SELECT id, title, summary, created  FROM postmortems WHERE {$parts}";
     $rows = array();
     $stmt = $conn->prepare($sql);
     $stmt->execute();
     $timezone = getUserTimezone();
     $tz = new DateTimeZone($timezone);
     while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
         $row['score'] = 0;
         $row['created'] = new DateTime("@{$row['created']}");
         $row['created']->setTimezone($tz);
         $row['created'] = $row['created']->format('m/d/Y G:ia');
         foreach ($terms_rx as $term_rx) {
             $row['score'] += preg_match_all("/{$term_rx}/i", $row['summary'], $null);
             $row['score'] += preg_match_all("/{$term_rx}/i", $row['title'], $null);
         }
         $rows[] = $row;
     }
     uasort($rows, 'Search::sort_results');
     $conn = null;
     return $rows;
 }
コード例 #4
0
ファイル: Model.php プロジェクト: atk4/data
 /**
  * Execute action.
  *
  * @param string $mode
  * @param array  $args
  *
  * @return \atk4\dsql\Query
  */
 public function action($mode, $args = [])
 {
     if (!$this->persistence) {
         throw new Exception(['action() requires model to be associated with db']);
     }
     return $this->persistence->action($this, $mode, $args);
 }
コード例 #5
0
 function createUser($username, $password, $role)
 {
     $i = Persistence::getInstance();
     $collection = 'users';
     $document = array('name' => $username, 'password' => $password, 'type' => $role);
     return $i->insertDocument($document, $collection);
 }
コード例 #6
0
ファイル: Persistence.php プロジェクト: aeberh/php-movico
 public function __construct()
 {
     $this->db = Singleton::create("DatabaseManager");
     if (is_null(self::$dbCache)) {
         self::$dbCache = BeanLocator::get("DatabaseCache");
     }
 }
コード例 #7
0
 public function eliminarDetalleProductoSucursalByProductolId($id)
 {
     $sql = new Sql();
     $sql->addTable('detalleProductoSucursales');
     $sql->setOpcion('delete');
     $sql->addWhere("`pedidoId =`" . $id);
     Persistence::eliminar($sql);
 }
コード例 #8
0
ファイル: Tipo.php プロジェクト: johncuervo24/EjPHP
 public function eliminarCategoria($id)
 {
     $sql = new Sql();
     $sql->addTable('tipos');
     $sql->setOpcion('delete');
     $sql->addWhere("`idTipo =`" . $id);
     Persistence::eliminar($sql);
 }
コード例 #9
0
ファイル: Categoria.php プロジェクト: johncuervo24/EjPHP
 public function modificarCategoria($id)
 {
     $sql = new Sql();
     $sql->addTable('categorias');
     $sql->setOpcion('update');
     $sql->addSet("`" . 'nombre' . "`" . "=" . "'" . $this->_nombre . "'");
     $sql->addWhere("`idCategoria =`" . $id);
     Persistence::modificar($sql);
 }
コード例 #10
0
ファイル: productos.php プロジェクト: johncuervo24/EjPHP
 public function modificar($table)
 {
     $sql = new SQL();
     $sql->addTable($table);
     $sql->setOpcion('update');
     $sql->addSet("`" . 'stock' . "`" . "=" . "'" . $this->_stock . "'");
     $sql->addWhere("`id`= " . $this->_id);
     Persistence::modificar($sql);
 }
コード例 #11
0
ファイル: Pedido.php プロジェクト: johncuervo24/EjPHP
 public function ingresar($table, $estado, $fecha, $productoId)
 {
     $sql = new SQL();
     $sql->addTable($table);
     $sql->setOpcion('insert');
     $sql->addInto('id' . "`,`" . 'estado' . "`,`" . 'fecha' . "`,`" . 'idProducto');
     $sql->addValues('NULL' . "','" . $estado . "','" . $fecha . "','" . $productoId);
     Persistence::insertar($sql);
 }
コード例 #12
0
ファイル: Routine.php プロジェクト: exildev/q-stad
 public function invoke()
 {
     $p = Persistence::getInstance();
     $_model = $this->get_called_class();
     $params = $this->getArray();
     $resp = $p->invoke($_model, $params);
     $arrayo = array();
     if ($resp) {
         foreach ($resp as $array) {
             array_push($arrayo, $array);
         }
     }
     return $arrayo;
 }
コード例 #13
0
ファイル: usuario.php プロジェクト: johncuervo24/EjPHP
 public function listar($table)
 {
     $sql = new SQL();
     $sql->addTable($table);
     $sql->setOpcion('listar');
     $usuarios = array();
     $lista = Persistence::consultar($sql);
     foreach ($lista as $usuario) {
         $id = $usuario['id'];
         $nombre = $usuario['nombre'];
         $apellido = $usuario['apellido'];
         $usuario = $usuario['correo'];
         $contrasenha = $usuario['contrasenha'];
         $usuarios[] = new usuario($id, $nombre, $apellido, $usuario, $contrasenha);
     }
     return $usuarios;
 }
コード例 #14
0
 public function insertar($_name, $_address, $_city, $_province, $_email, $_country, $_shippingMethod, $_paymentMethod, $_zipCode, $_phone)
 {
     $instance = Persistence::getInstance();
     $arregloCabeza = array("price" => $this->_price);
     $arregloCuerpo = array("productos" => $this->_productos);
     $name = array('name' => $_name);
     $address = array('address' => $_address);
     $city = array('city' => $_city);
     $province = array('city' => $_province);
     $email = array('email' => $_email);
     $country = array('country' => $_country);
     $shippingMethod = array('shippingMethod' => $_shippingMethod);
     $paymentMethod = array('paymentMethod' => $_paymentMethod);
     $zipCode = array('zipCode' => $_zipCode);
     $phone = array('phone' => $_phone);
     $arregloFinal = array_merge($arregloCabeza, $arregloCuerpo, $name, $address, $city, $province, $email, $country, $shippingMethod, $paymentMethod, $zipCode, $phone);
     $instance->insertDocument($arregloFinal, 'orders');
 }
コード例 #15
0
ファイル: Collect.php プロジェクト: exildev/q-stad
 public function get()
 {
     $user = Session::get_user();
     $p = Persistence::getInstance();
     $_model = $this->model->get_called_class();
     $array = $this->filter;
     if ($this->model instanceof User) {
         $_packa = null;
         $array['hashtype'] = $this->model->getHashType()->val();
     } else {
         $_packa = $this->model->get_package();
     }
     $resp = $p->filter($user, $_packa, strtolower($_model), $array);
     $arrayo = array();
     $class = get_class($this->model);
     if ($resp) {
         foreach ($resp as $array) {
             $object = new $class();
             $object->setArray($array);
             array_push($arrayo, $object);
         }
     }
     return $arrayo;
 }
コード例 #16
0
ファイル: Persistence.php プロジェクト: johncuervo24/EjPHP
 public static function modificar(Sql $sql)
 {
     $db = Persistence::_conectarBD();
     $db->ejecutar($sql);
 }
コード例 #17
0
ファイル: routes.php プロジェクト: lursu/morgue
        echo "Mail sent!";
    } else {
        echo "Error sending mail";
    }
    return;
});
$app->get("/calendar/facilitators/add/:id", function ($id) use($app) {
    $config = Configuration::get_configuration('calendar');
    if (!$config["facilitator"]) {
        return;
    }
    $user = MorgueAuth::get_auth_data();
    $facilitator = array();
    $facilitator['name'] = $user['username'];
    $facilitator['email'] = Contact::get_email_for_user($user['username']);
    $conn = Persistence::get_database_object();
    $error = Calendar::set_facilitator($id, $facilitator, $conn);
    if (!$error) {
        $userHtml = Contact::get_html_for_user($user['username']);
        $to = implode(", ", $config["facilitators_email"]);
        $from = "Morgue <*****@*****.**>";
        $subject = "Facilitator needed [PM-{$id}]";
        $message = '
            <html>
            <head>
              <title>Facilitator Needed for PM-' . $id . '</title>
            </head>
            <body style="font-family: \'Helvetica Neue\', Helvetica,Arial, sans-serif;">
              <h3>' . $userHtml . ' will facilitate this post-mortem!</h3>
            </body>
            </html>';
コード例 #18
0
ファイル: Postmortem.php プロジェクト: nlsun/morgue
 /**
  * function to get all history records for a postmortem
  *
  * @param $event_id - ID of the postmortem
  * @param $conn - PDO connection object
  *
  * @returns array - Array containing an entry for each
  * associated history record
  */
 static function get_history($event_id, $conn = null)
 {
     $conn = $conn ?: Persistence::get_database_object();
     if (is_null($conn)) {
         return array("status" => self::ERROR, "error" => "Couldn't get connection object.");
     }
     $sql = "SELECT * FROM postmortem_history WHERE postmortem_id=:pid";
     $stmt = $conn->prepare($sql);
     $stmt->execute(array("pid" => $event_id));
     return $stmt->fetchAll();
 }
コード例 #19
0
ファイル: index.php プロジェクト: robabby/boilerplate
<?php

require 'Persistence.php';
$comment_post_ID = 1;
$db = new Persistence();
$comments = $db->get_comments($comment_post_ID);
$has_comments = count($comments) > 0;
?>
<!DOCTYPE html>
<html lang="en-US">
<head>
	<title>Smashing HTML5!</title>
	<meta charset="utf-8" />
	
	<link rel="stylesheet" href="css/main.css" type="text/css" />

	<!--[if IE]>
	  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
	<!--[if lte IE 7]>
		<link rel="stylesheet" type="text/css" media="all" href="css/ie.css"/>
		<script src="js/IE8.js" type="text/javascript"></script><![endif]-->	
	<!--[if lt IE 7]>
		<link rel="stylesheet" type="text/css" media="all" href="css/ie6.css"/><![endif]-->

</head>

<body id="index" class="home">
	
	<header id="banner" class="body">
		<h1><a href="#">Smashing HTML5! <strong>HTML5 in the year <del>2022</del> <ins>2012</ins></strong></a></h1>
		<nav><ul>
コード例 #20
0
ファイル: Persistence.php プロジェクト: nlsun/morgue
 /**
  * Get a postmortem from the database
  *
  * @param $postmortem_id - id of the postmortem to get
  * @param $conn          - PDO connection object, will be newly instantiated when
  *                         null (default: null)
  *
  * @returns a postmortem map including an "id" field on success or a map of the
  * form ( "id" => null, "error" => "an error message" ) on failure
  */
 static function get_postmortem($postmortem_id, $conn = null)
 {
     $conn = $conn ?: Persistence::get_database_object();
     try {
         $sql = "SELECT id, title, summary, why_surprised, starttime, endtime, statustime,\n                    detecttime,severity, contact, gcal, created, modified, modifier, deleted \n                    FROM postmortems WHERE id = :id LIMIT 1";
         $stmt = $conn->prepare($sql);
         $stmt->execute(array('id' => $postmortem_id));
         $postmortem = $stmt->fetch(PDO::FETCH_ASSOC);
         return $postmortem;
     } catch (PDOException $e) {
         return array("id" => null, "error" => $e->getMessage());
     }
 }
コード例 #21
0
ファイル: routes.php プロジェクト: lursu/morgue
 $content = "anniversary/views/anniversary-mail";
 $show_sidebar = false;
 $page_title = "Today in Post Mortem History";
 $today = date("Y-m-d", time());
 $get_date = trim($app->request->get('date'));
 if ($get_date) {
     $get_date = date("Y-m-d", strtotime($get_date));
     $today = $get_date;
 }
 $conn = Persistence::get_database_object();
 $pm_ids = Anniversary::get_ids($today, $conn);
 $human_readable_date = date("F jS", strtotime($today));
 $pms = array();
 if ($pm_ids['status'] === 0) {
     foreach ($pm_ids['values'] as $k => $v) {
         $pm = Persistence::get_postmortem($v['id'], $conn);
         $pms[] = $pm;
     }
 } else {
     $message = $pm_ids['error'];
     $content = "error";
     include 'views/page.php';
     return;
 }
 if (count($pms)) {
     // get the tags for each PM we found so we can display them
     foreach ($pms as $k => $pm) {
         $tags = Postmortem::get_tags_for_event($pm['id'], null);
         $pms[$k]['tags'] = $tags['values'];
     }
 }
コード例 #22
0
ファイル: lib.php プロジェクト: lursu/morgue
 /**
  * function to UNdelete a channel from the association table
  *
  * @param $id - ID to delete
  * @param $conn - PDO connection object (default: null)
  *
  * @returns ( "status" => self::OK ) on success
  * or ( "status" => self::ERROR, "error" => "an error message" ) on failure
  */
 static function undelete_channel($theid, $conn = null)
 {
     $conn = $conn ?: Persistence::get_database_object();
     $table_name = 'irc';
     if (is_null($conn)) {
         return array("status" => self::ERROR, "error" => "Couldn't get connection object.");
     }
     return Persistence::flag_as_undeleted($table_name, 'postmortem_id', $theid, $conn);
 }
コード例 #23
0
ファイル: User.php プロジェクト: exildev/q-stad
 public function autenticate()
 {
     $p = Persistence::getInstance();
     return $p->autenticate($this);
 }
コード例 #24
0
ファイル: clear.php プロジェクト: rolka/realtime-commenting
<?php

require 'Persistence.php';
$db = new Persistence();
$db->delete_all();
print_r($db->get_all_comments());
コード例 #25
0
ファイル: Pedido.php プロジェクト: johncuervo24/EjPHP
 public function eliminarPedido($id)
 {
     $sql = new Sql();
     $sql->addTable('pedidos');
     $sql->setOpcion('delete');
     $sql->addWhere("`idPedido =`" . $id);
     Persistence::eliminar($sql);
 }
コード例 #26
0
 /**
  * @dataProvider persistanceInstanceProvider
  */
 public function testDetach(Persistence $persistence)
 {
     $document = $this->collection->createDocument(array('param' => 'value'));
     $this->assertFalse($persistence->contains($document));
     // attach document
     $persistence->persist($document);
     // check if document in persistence
     $this->assertTrue($persistence->contains($document));
     // detach document
     $persistence->detach($document);
     // check if document in persistence
     $this->assertFalse($persistence->contains($document));
 }
コード例 #27
0
<?php

namespace Components;

Annotations::registerAnnotations([Annotation_Cache::NAME => Annotation_Cache::TYPE, Annotation_Collection::NAME => Annotation_Collection::TYPE, Annotation_Id::NAME => Annotation_Id::TYPE, Annotation_Transient::NAME => Annotation_Transient::TYPE]);
Resource_Type::registerResourceType('mysql', Persistence_Resource_Pdo_Mysql::type());
Resource_Type::registerResourceType('mongodb', Persistence_Resource_Mongodb::type());
Persistence_Resource_Schema::serve('schema');
Persistence::registerResource('nosql', ['mongodb://127.0.0.1/' . COMPONENTS_INSTANCE_CODE]);
Debug::addFlagListener(function ($active_, array $flags_) {
    if ($active_) {
        $bits = [];
        if (isset($flags_[Persistence::LOG_STATEMENTS])) {
            $bits[] = Persistence::BIT_LOG_STATEMENTS;
        }
        if (isset($flags_[Persistence::LOG_QUERIES])) {
            $bits[] = Persistence::BIT_LOG_QUERIES;
        }
        if (isset($flags_[Persistence::PROFILE])) {
            $bits[] = Persistence::BIT_PROFILE;
        }
        Persistence::$debugMode = Bitmask::getBitmaskForBits($bits);
    } else {
        Persistence::$debugMode = Persistence::BIT_NO_DEBUG;
    }
});
コード例 #28
0
<?php

require 'Persistence.php';
$ajax = $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest';
$db = new Persistence();
$added = $db->add_comment($_POST);
if ($ajax) {
    sendAjaxResponse($added);
} else {
    sendStandardResponse($added);
}
function sendAjaxResponse($added)
{
    header("Content-Type: application/x-javascript");
    if ($added) {
        header('Status: 201');
        echo json_encode($added);
    } else {
        header('Status: 400');
    }
}
function sendStandardResponse($added)
{
    if ($added) {
        header('Location: index.php');
    } else {
        header('Location: index.php?error=Your comment was not posted due to errors in your form submission');
    }
}
コード例 #29
0
 public function loadImage($id)
 {
     return $image = Persistence::getImagen($id);
 }
コード例 #30
0
ファイル: Proveedor.php プロジェクト: johncuervo24/EjPHP
 public function modificarProveedor($id)
 {
     $sql = new Sql();
     $sql->addTable('proveedores');
     $sql->setOpcion('update');
     $sql->addSet("`" . 'nombre' . "`" . "=" . "'" . $this->_nombreContacto . "'");
     $sql->addSet("`" . 'apellido' . "`" . "=" . "'" . $this->_apellidoContacto . "'");
     $sql->addSet("`" . 'dni' . "`" . "=" . "'" . $this->_dniContacto . "'");
     $sql->addSet("`" . 'telefono' . "`" . "=" . "'" . $this->_telefonoContacto . "'");
     $sql->addSet("`" . 'empresa' . "`" . "=" . "'" . $this->_nombreEmpresa . "'");
     $sql->addSet("`" . 'ruc' . "`" . "=" . "'" . $this->_ruc . "'");
     $sql->addSet("`" . 'correo' . "`" . "=" . "'" . $this->_correo . "'");
     $sql->addWhere("`idProveedor` =" . $id);
     Persistence::modificar($sql);
 }