【发布时间】: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