本文整理汇总了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;
}
}
}
示例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;
}
}
}
示例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;
}
}
}
示例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;
}
}
}