当前位置: 首页>>代码示例>>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;未经允许,请勿转载。