當前位置: 首頁>>代碼示例>>PHP>>正文


PHP People::getAll方法代碼示例

本文整理匯總了PHP中People::getAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP People::getAll方法的具體用法?PHP People::getAll怎麽用?PHP People::getAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在People的用法示例。


在下文中一共展示了People::getAll方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: array

    /*
     * FORMA RESUZIADA:
     * Alterando um registro no banco de dados
     */
    \People::newInstance($id)->delete();
    /*
     * Obdendo vários registros do banco de dados
     */
    $people = new \People();
    $where = "name LIKE '%Rafael%' OR email LIKE '%gmail%'";
    $order = array('id DESC', 'name ASC');
    $limit = array(1000, 0);
    //$group = array('birthDate');
    $group = null;
    //Resultado: array(Class People), Uma array com várias instâncias da classe People.
    $peoples = $people->getAll($where, $order, $limit, $group);
    /*
     * FORMA RESUZIADA:
     * Obdendo vários registros do banco de dados
     */
    $peoples = \People::newInstance()->getAll("name LIKE '%Rafael%' OR email LIKE '%gmail%'");
    foreach ($peoples as $people) {
        echo $people->getName() . "\n";
    }
    /*
     * Obtendo a quantidade de registros existentes no banco de dados.
     * Esse método utiliza menos esforço do banco de dados pois não obtem os dados do registro, apenas faz a contagem deles diretamente no banco de dados.
     * O resultado é um número inteiro.
     */
    $total = \People::newInstance()->countAll("name LIKE '%Rafael%' OR email LIKE '%gmail%'");
} catch (Exception $ex) {
開發者ID:rafaelscbr,項目名稱:ORM,代碼行數:31,代碼來源:usingCRUD.php

示例2: session_start

<?php

require_once __DIR__ . "/../vendor/autoload.php";
require_once __DIR__ . "/../src/People.php";
session_start();
if (empty($_SESSION['address_book'])) {
    $_SESSION['address_book'] = array();
}
$app = new Silex\Application();
$app['debug'] = true;
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('address_book.html.twig', array('people' => People::getAll()));
});
$app->post("/people", function () use($app) {
    $person = new People($_POST['name'], $_POST['phone_number'], $_POST['address']);
    $person->save();
    return $app['twig']->render('add_contact.html.twig', array('newperson' => $person));
});
$app->post("/delete_all", function () use($app) {
    People::deleteAll();
    return $app['twig']->render('delete_all.html.twig');
});
return $app;
開發者ID:JordanNavratil,項目名稱:Address_book,代碼行數:24,代碼來源:app.php


注:本文中的People::getAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。