如何将我的数组发送到我的api

时间:2013-06-18 17:58:51

标签: cakephp httpclient

我试图将我的数组($ conditions)转移到我的api(@pagination_condition)。任何人都有任何线索。谢谢 客户代码:

$tofind = $this->request->query;
$conditions = array( `enter code here`
                        array( 
                        "TransactionInfo.created >= " => "$startDate_finder", 
                        "TransactionInfo.created <=" => "$endDate_finder" 
                        ), 
                        "OR" => array( 
                        array( "User.first_name LIKE " => "%$keyword_finder%" ),
                        array( "User.last_name LIKE " => "%$keyword_finder%" )
                        ),
                        "ORDER" => array("TransactionInfo.created" => "desc"),
                        "limit" => 30
                      );
        $response = json_decode($this->HTTPClient->get($this->apiUrl . "users/search/page:{$query}.json", $tofind."&condition="json_encode($conditions)), true);

我的api代码:

if ($this->request->is('get')) {
        $finder = $this->request->query;
        $pagination_conditions = array(
            'conditions' => null, //array('Model.field' => $thisValue), //array of conditions
            'recursive' => 1, //int
            'fields' => null, //array('Model.field1', 'DISTINCT Model.field2'), //array of field names
            'order' => null, //array('Model.created', 'Model.field3 DESC'), //string or array defining order
            'group' => null, //array('Model.field'), //fields to GROUP BY
            'limit' => null, //n, //int
            'page' => null, //n, //int
            'offset' => null, //n, //int
            'callbacks' => true, //true //other possible values are false, 'before', 'after'
        );
        $pagination_conditions = array_merge($pagination_conditions, json_decode($conditions));

我希望客户端设置的条件数组覆盖api中的pagination_condition。你的线索将非常感谢。提前谢谢。

0 个答案:

没有答案