小编Ahm*_*amy的帖子

通过我的REST API连接Google REST API无效

我有这个应用程序具有以下结构 在此输入图像描述

我正在使用rest客户端库 https://github.com/philsturgeon/codeigniter-restclient 连接到MyAPI并使用php api客户端 http://code.google.com/p/google-api-php-client/进行连接到Google API

我的控制器代码如下

 function index()
    {
        if($this->form_validation->run())
        {
           $logged = $this->rest->get('auth/user',array(
               'email'=>$this->input->post('email')
                   )); 
           var_dump($logged);
        }
        $this->load->view('layout/login',$this->data);
    }
Run Code Online (Sandbox Code Playgroud)

我处理此请求的API代码如下所示,以确保用户存在于我的数据库中并通过Google进行身份验证

function user_get()
    {
        $response=NULL;
        $data=array(
            'email'=>$this->get('email')
        );
        $google_account=$this->google->authenticate();
        if(  isset($google_account) && $this->user_model->login($data))
        {
            $response->status='success';
            $response->message=$google_account;
        }
        else
        {
            $response->status='error';
            $response->message='Failed to authenticate user';   
        }
        $this->response($response,200);
    }
Run Code Online (Sandbox Code Playgroud)

Google库函数`Authenticate'如下

function authenticate()
    {
        $oauth2 = new Google_Oauth2Service($this->client);
        if (isset($_GET['code']))
        {
            $this->client->authenticate($_GET['code']);
            $_SESSION['token'] = $this->client->getAccessToken();
            $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
            header('Location: …
Run Code Online (Sandbox Code Playgroud)

php api rest web-services codeigniter

5
推荐指数
1
解决办法
1781
查看次数

codeigniter mysql视图与查询

我正在使用Codeigniter进行开发,当我遇到复杂的数据库查询时,我正在使用它

$this->db->query('my complicated query');
Run Code Online (Sandbox Code Playgroud)

然后使用转换为对象数组 $query->result();

到目前为止它非常好用

现在我的问题是

  1. 如果我想创建mysql视图并从中进行选择怎么办?将

    $this->db->from('mysql_view')
    
    Run Code Online (Sandbox Code Playgroud)

    把mysql视图看成是不是表?

  2. 如果我这样做,那么性能上的差异会比正常的数据库查询更快吗?

  3. Codeigniter和MYSQL数据库处理复杂查询的最佳做法是什么,因为我理解ActiveRecord只是查询构建器,而且有些测试它甚至有点慢

在此先感谢您的建议

mysql performance activerecord codeigniter query-optimization

4
推荐指数
1
解决办法
2558
查看次数