Hello,
I have following issue when trying to insert into database. I have already used this approach few times and it always worked for me. Now it doesn't want to work and I have no idea how to solve this. Please help
blad:
Quote:("You must use the "set" method to update an entry.")
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Post_model extends CI_Model {
public function create( $post )
{
$this->db->insert( 'posts' , $post );
}
}
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Post extends CI_Controller {
public function __construct()
{
parent::__construct();
$post = file_get_contents( 'php://input' );
$_POST = json_decode( $post , true );
$this->load->model( 'site/Post_model' );
}
public function create()
{
$post = $this->input->post('post');
$this->Post_model->create( $post );
}
}
/* End of file Post.php */
/* Location: ./application/controllers/Post.php */
Code:
controllersUser.controller('postCreate', ['$scope','$http', function($scope, $http){
$scope.formSubmit = function(post)
{
$http.post('api/site/post/create/',{
question: post.question,
answers: post.answer,
votes: post.votes
}).success(function(data){
console.log('post dodany');
}).error(function(){
console.log('post NIE dodany');
});
};
}]);
Code:
<div>
<input type="text" ng-model="post.question">
<input type="text" ng-model="post.answer">
<input type="number" ng-model="post.votes">
</div>