我的问题是当我在SUITECRM中创建新用户时,我想在另一个应用程序和其他CodeIgniter数据库中插入数据。
请帮助我,了解如何解决上述问题。
我创建了自定义插入插件api,如:
<?php
// required headers
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
header("Access-Control-Allow-Methods: POST");
header("Access-Control-Max-Age: 3600");
header("Access-Control-Allow-Headers: Content-Type, Access-Control-Allow-Headers, Authorization, X-Requested-With");
// get database connection
include_once '../config/database.php';
// instantiate product object
include_once '../objects/product.php';
$database = new Database();
$db = $database->getConnection();
$product = new Product($db);
//get posted data
$data = (object) $_POST;
//$data = json_decode(file_get_contents("php://input"));
// set product property values
$product->name = $data->name;
$product->description = $data->description;
$product->price = $data->price;
$product->category_id = $data->category_id;
$product->created = date('Y-m-d H:i:s');
// create the product
if($product->create()){
echo '{';
echo '"message": "Product was created."';
echo '}';
}
// if unable to create the product, tell the user
else{
echo '{';
echo '"message": "Unable to create product."';
echo '}';
}
?>