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


PHP model::getAll方法代码示例

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


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

示例1: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $page = Input::get('page', 1);
     $limit = Input::get('limit', 10);
     $sortBy = Input::get('sortBy', 'sort_order');
     $sortDirection = Input::get('sortDirection', 'asc');
     $all = Input::get('all', false);
     if (!$all) {
         $data = $this->model->getByPage($page, $limit, $sortBy, $sortDirection, []);
     } else {
         // Grab all the contacts
         $data = $this->model->getAll($sortBy, $sortDirection);
     }
     return Response::json($data);
 }
开发者ID:khaledof,项目名称:brikaCms,代码行数:20,代码来源:ApiContactsController.php

示例2: model

                        <input type="password" name="password"  class="form-control">
                    </div>
                </div>
                <div class="panel-footer">
                    <input type="submit" class="btn btn-success" name="login_btn" value="login">
                    <a href="' . SITE_DIR . '" class="btn btn-default">Cancel</a>
                </div>
            </div>
        </div>
        </form>
    </div>
    ';
}
if ($_SESSION['login'] == 'admin') {
    $model = new model('unsubscribers');
    $unsubscribers = $model->getAll('udate DESC');
    if (isset($_POST['export'])) {
        $string = 'id;email;date' . "\n";
        foreach ($unsubscribers as $row) {
            $string .= $row['id'] . ';' . $row['email'] . ';' . date('Y-m-d H:i', strtotime($row['udate'])) . "\n";
        }
        header('Content-type:application/csv');
        header('Content-Disposition:attachment;filename=detox_subscribers_' . date('y-m-d') . '.csv');
        echo $string;
        exit;
    }
    echo date('Y-m-d H:i:s');
    echo '
<br><br><br>
    <div class="row">
        <div class="col-md-10 col-md-offset-1 col-sm-12">
开发者ID:novichkovv,项目名称:lonty,代码行数:31,代码来源:unsubscribers_list.php

示例3: function

// we recommend you see the example model before see this controller
_::define_controller('example_4', function () {
    // if you need redirect te code to other controller
    // isn't necessary redirect the client, you can redirect the code using
    // _::redirect('new controller');
    // this line call new controller, and stop execution of current.
    _::redirect('example_3');
    // from here it doesn't execute.
    // if you like redirect client web browser, use:
    _::redirect('http://google.com', false);
    // this stop execution of current code.
    // if you need make all records of a table, you can use:
    $records = model::getAll();
    // this is SELECT * FROM TABLE;
    // if you like add limit, you can use second parammeter:
    $records = model::getAll('LIMIT 1');
    // in the second parammeter you can use WHERE clausule, ORDER BY and LIMIT.
    // getAll is a magic function of ORM, you don't need define it in the model.
    // now, $records get an Array of ids, you need make one object at each.
    // you can use foreach:
    /**
     $objects = array();
     foreach($records as $one_record)
     {
       $objects[] = new model($one_record['primary_key']);
     }
    */
    // OR YOU CAN USE FRAMEWORK TO MAKE EASY:
    $objects = _::factory($records, 'primary_key', 'model');
    // of course, you replace primary_key and model.
    // now you have one object each record.
开发者ID:alexander171294,项目名称:phpquery,代码行数:31,代码来源:example.php


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