选择语言 :

 Module_OOP_ORM_Finder_REST::find

获取数据

OOP_ORM_Result Module_OOP_ORM_Finder_REST::find( [ $query $query = null ] )

参数列表

参数 类型 描述 默认值
$query $query 请求的参数 null
返回值
  • OOP_ORM_Result
File: ./modules/oop/orm/finder/rest.class.php
public function find($query = null)
{
    if (!$this->api_url)
    {
        throw new Exception(__('orm api url is not declared.'));
    }

    $url = $this->parse_api_fullurl($query);

    try
    {
        if ($this->method=='POST')
        {
            $rs = (string)$this->driver()->post($url, $this->parse_api_post_data($query));
        }
        else if ($this->method=='PUT')
        {
            $rs = (string)$this->driver()->put($url, $this->parse_api_post_data($query));
        }
        else if ($this->method=='DELETE')
        {
            $rs = (string)$this->driver()->delete($url);
        }
        else
        {
            if ($this->method!='GET')
            {
                $this->driver()->method($this->method);
            }

            $rs = (string)$this->driver()->get($url);
        }
    }
    catch (Exception $e)
    {
        Core::debug()->error('ORM获取数据失败,URL:' . $url);
        $rs = '[]';
    }

    $this->last_query = $url;

    // 处理解析数据
    $this->parse_result_data($rs);

    // 重置数据
    $this->reset();

    return $this->create_group_data($rs, true);
}