[英]PHP F3 find escaping limit and offset conditions
I was introduced to the PHP Fat Free Framework yesterday and I am now exploring its possibilities for my REST api. 昨天我被介绍给PHP Fat Free Framework,现在我正在探索我的REST api的可能性。 I am now trying to do a select query with limit and offset parameters.
我现在正在尝试使用限制和偏移量参数进行选择查询。 Following its documentation, I came up with the following:
根据其文档,我提出了以下内容:
$query = array('userid=?', F3::get('userid'));
$extra = array(
'order' =>'id DESC',
'offset' => isset($_GET['offset']) ? (int)$_GET['offset'] : 0,
'limit' => isset($_GET['limit']) ? (int)$_GET['limit'] : 5
);
$list = $this->mapper->find($query, $extra);
However, while I was under the impression that F3 would handle the escaping, it doesn't. 但是,虽然我给人以F3可以处理转义的印象,但事实并非如此。 Am I using the framework in the wrong way, or how should I handle the escaping here?
我是否以错误的方式使用框架,还是应该在此处处理转义?
Instead of using find()
you should use paginate()
like this: 而不是使用
find()
您应该像这样使用paginate()
:
$list = $this->mapper->paginate(2, 5, array('userid=?', F3::get('userid')));
Check out the docs, it's quite easy to use. 查看文档,它很容易使用。 The result is different than
find()
, though, since it contains more info. 结果与
find()
不同,因为它包含更多信息。 The items returned will be in $list['subset']. 返回的项目将在$ list ['subset']中。 You can do a var_dump of $list to see the other fields returned.
您可以执行$ list的var_dump以查看返回的其他字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.