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


PHP Registry::getDb方法代码示例

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


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

示例1: select

 /**
  * Object selection
  *
  * @param array   $data       Conditionals and Order values
  * @param integer $limit      Limit
  * @param integer $limitStart Limit start
  * @param int     $total      Total rows found
  *
  * @return array Objects found
  */
 public static function select($data = array(), $limit = 0, $limitStart = 0, &$total = null)
 {
     $db = Registry::getDb();
     //Query
     $query = "SELECT * FROM `tipos` ";
     $params = array();
     //Where
     $where = " WHERE 1=1 ";
     $query .= $where;
     //Total
     $totalQuery = "SELECT * FROM `tipos` " . $where;
     $total = count($db->Query($totalQuery, $params));
     if ($total) {
         //Order
         if ($data['order'] && $data['orderDir']) {
             //Secure Field
             $orders = array("ASC", "DESC");
             if (@in_array($data['order'], array_keys(get_class_vars(__CLASS__))) && in_array($data['orderDir'], $orders)) {
                 $query .= " ORDER BY `" . $data['order'] . "` " . $data['orderDir'];
             }
         }
         //Limit
         if ($limit) {
             $query .= " LIMIT " . (int) $limitStart . ", " . (int) $limit;
         }
         $rows = $db->Query($query, $params);
         if (count($rows)) {
             $results = array();
             foreach ($rows as $row) {
                 $results[] = new Tipo($row);
             }
             return $results;
         }
     }
 }
开发者ID:flafuente,项目名称:parrillas,代码行数:45,代码来源:Tipo.php

示例2: select

 /**
  * Object selection
  *
  * @param array   $data       Conditionals and Order values
  * @param integer $limit      Limit
  * @param integer $limitStart Limit start
  * @param int     $total      Total rows found
  *
  * @return array Objects found
  */
 public static function select($data = array(), $limit = 0, $limitStart = 0, &$total = null)
 {
     $db = Registry::getDb();
     //Query
     $query = "SELECT * FROM `users` ";
     $params = array();
     //Where
     $where = " WHERE 1=1 ";
     //Search
     if ($data["search"]) {
         $where .= "AND (`username` LIKE :username OR `email` LIKE :email )";
         $params[":username"] = "%" . $data["search"] . "%";
         $params[":email"] = "%" . $data["search"] . "%";
     }
     //Status
     if (isset($data["statusId"]) && $data["statusId"] != "-1") {
         $where .= " AND `statusId` = :statusId ";
         $params[":statusId"] = $data["statusId"];
     }
     $query .= $where;
     //Total
     $totalQuery = "SELECT * FROM `users` " . $where;
     $total = count($db->Query($totalQuery, $params));
     if ($total) {
         //Order
         if ($data['order'] && $data['orderDir']) {
             //Secure Field
             $orders = array("ASC", "DESC");
             if (@in_array($data['order'], array_keys(get_class_vars(__CLASS__))) && in_array($data['orderDir'], $orders)) {
                 $query .= " ORDER BY `" . $data['order'] . "` " . $data['orderDir'];
             }
         }
         //Limit
         if ($limit) {
             $query .= " LIMIT " . (int) $limitStart . ", " . (int) $limit;
         }
         $rows = $db->Query($query, $params);
         if (count($rows)) {
             $results = array();
             foreach ($rows as $row) {
                 $results[] = new User($row);
             }
             return $results;
         }
     }
 }
开发者ID:flafuente,项目名称:parrillas,代码行数:56,代码来源:User.php

示例3: select

 /**
  * Obtiene registros de la base de datos.
  * @param  array   $data       Condicionales / ordenación
  * @param  integer $limit      Límite de resultados (Paginación)
  * @param  integer $limitStart Inicio de la limitación (Paginación)
  * @param  int     $total      Total de filas encontradas (Paginación)
  * @return array   Modelos de la clase actual
  */
 public function select($data = array(), $limit = 0, $limitStart = 0, &$total = null)
 {
     $db = Registry::getDb();
     //Query
     $query = "SELECT * FROM `eventos` WHERE 1=1 ";
     $params = array();
     //Where
     if (isset($data["fecha"])) {
         $query .= " AND `fechaInicio` >= :fechaInicio AND `fechaFin` <= :fechaFin ";
         $params[":fechaInicio"] = $data["fecha"] . " 03:00:00:00";
         $params[":fechaFin"] = date("Y-m-d 02:59:59:24", strtotime($data["fecha"] . " +1 day"));
     }
     if ($data["orderNum"]) {
         $query .= " AND `order` = :orderNum ";
         $params[":orderNum"] = $data["orderNum"];
     }
     if ($data["minOrderNum"]) {
         $query .= " AND `order` >= :minOrderNum ";
         $params[":minOrderNum"] = $data["minOrderNum"];
     }
     //Tipo
     if ($data["tipo"]) {
         $query .= "AND `tipo` IN (SELECT `id` FROM `tipos` WHERE `codigo` = :tipo) ";
         $params[":tipo"] = $data["tipo"];
     }
     //Total
     $total = count($db->Query($query, $params));
     if ($total) {
         //Order
         if ($data['order'] && $data['orderDir']) {
             //Secure Field
             $orders = array("ASC", "DESC");
             if (@in_array($data['order'], array_keys(get_class_vars(__CLASS__))) && in_array($data['orderDir'], $orders)) {
                 $query .= " ORDER BY `" . $data['order'] . "` " . $data['orderDir'];
             }
         } else {
             $query .= " ORDER BY `order` ASC ";
         }
         //Limit
         if ($limit) {
             $query .= " LIMIT " . (int) $limitStart . ", " . (int) $limit;
         }
         $rows = $db->Query($query, $params);
         if (count($rows)) {
             foreach ($rows as $row) {
                 $results[] = new Evento($row);
             }
             return $results;
         }
     }
 }
开发者ID:flafuente,项目名称:parrillas,代码行数:59,代码来源:Evento.php

示例4: select

 /**
  * Object selection
  *
  * @param array   $data       Conditionals and Order values
  * @param integer $limit      Limit
  * @param integer $limitStart Limit start
  * @param int     $total      Total rows found
  *
  * @return array Objects found
  */
 public static function select($data = array(), $limit = 0, $limitStart = 0, &$total = null)
 {
     $db = Registry::getDb();
     //Query
     $query = "SELECT * FROM `entradas` ";
     $params = array();
     //Where
     $where = " WHERE 1=1 ";
     //Search
     if ($data["search"]) {
         $where .= "AND (`nombre` LIKE :nombre OR `houseNumber` LIKE :houseNumber) ";
         $params[":houseNumber"] = "%" . $data["search"] . "%";
         $params[":nombre"] = "%" . $data["search"] . "%";
     }
     //Tipo
     if ($data["tipo"]) {
         $where .= "AND `tipoId` IN (SELECT `id` FROM `tipos` WHERE `codigo` = :tipo) ";
         $params[":tipo"] = $data["tipo"];
     }
     //Vinculada
     if (isset($data["vinculada"]) && $data['vinculada'] != -1) {
         if ($data['vinculada']) {
             $where .= "AND `programaId` > 0 ";
         } else {
             $where .= "AND (`programaId` = 0 OR  `programaId` IS NULL) ";
         }
     }
     $query .= $where;
     //Total
     $totalQuery = "SELECT * FROM `entradas` " . $where;
     $total = count($db->Query($totalQuery, $params));
     if ($total) {
         //Order
         if ($data['order'] && $data['orderDir']) {
             //Secure Field
             $orders = array("ASC", "DESC");
             if (@in_array($data['order'], array_keys(get_class_vars(__CLASS__))) && in_array($data['orderDir'], $orders)) {
                 $query .= " ORDER BY `" . $data['order'] . "` " . $data['orderDir'];
             }
         }
         //Limit
         if ($limit) {
             $query .= " LIMIT " . (int) $limitStart . ", " . (int) $limit;
         }
         $rows = $db->Query($query, $params);
         if (count($rows)) {
             $results = array();
             foreach ($rows as $row) {
                 $results[] = new Entrada($row);
             }
             return $results;
         }
     }
 }
开发者ID:flafuente,项目名称:parrillas,代码行数:64,代码来源:Entrada.php


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