【问题标题】:Cannot insert data into multiple databases Codeigniter (MongoDB and MySQL)无法将数据插入多个数据库 Codeigniter(MongoDB 和 MySQL)
【发布时间】:2016-10-28 02:52:15
【问题描述】:

我正在参考https://github.com/chriskacerguis/codeigniter-restserver开发一个rest api服务器。我正在使用 Mongo 和 Mysql 来保存 api 响应。我的控制器保存 webhook 端点响应。我可以将数据保存到 Mongo,但 MYSQL 不工作。请指教。

我的控制器 - Hooks.php

  public function opened_post() {

//        $_POST = $this->request->body;

        //Get the message id
        if(!$mid = $this->input->post('message-id')) $this->response(array("status" => true));

        //Parse message ID
        $mid = explode("@", $mid, 2)[0];

        //Update the record
         $this->mail_store->mid($mid)->data(array('opened' => true))->update();


  $this->load->model('message_store');
  $this->messages_store->add();

        $this->response(array("status" => "success"));
    }

我的模型 - Message_store.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');


class Message_store extends CI_Model {

    public function __construct() {
        // Call the Model constructor
        parent::__construct();

    }

    /**
     * Store message into queue
     */
    public function add($event, $data, $token) {

        {

        $store = array('event' => 'HOOK', 'data' => 'Grap', 'token' => 'ABC12345');

          $this->db->insert($store->hooks, $store);
        }

        //Clear
        $this->clear_();
    }


}


?>

【问题讨论】:

    标签: php mysql json mongodb codeigniter


    【解决方案1】:

    开发了一个单独的 PHP 文件,要求 Restserver 在 Mongo 和 MYSQL 中保存 webhook。

    问题已解决

    【讨论】:

      猜你喜欢
      • 2017-10-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-23
      • 2019-06-07
      • 2015-07-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多