2
https://github.com/chriskacerguis/codeigniter-restserverを参照して残りのAPIサーバーを開発しています。私はMongoとMysqlを使ってAPIの応答を保存しています。私のコントローラーはwebhooksエンドポイント応答を保存します。私はMongoにデータを保存できますが、MYSQLは機能しません。ご意見をお聞かせください。複数のデータベースにデータを挿入できませんCodeigniter(MongoDBと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_();
}
}
?>