我已经创建了一个插入程序,但是不知道如何调用参数" name"和"路径"在控制器和模型中
存储过程:
CREATE DEFINER=`root`@`localhost`
PROCEDURE `insert_document_details`
(IN `name` VARCHAR(50), IN `path` VARCHAR(255) )
BEGIN
INSERT INTO `document_details`
(`document_name`, `document_path`)
VALUES (name,path);
END
路线:
Route::post('insert_document_details/{name}/{path}',array('as'=>'insert_document_details',
'uses'=>'AuthorsController@post_document_details'));
AuthorController:
class AuthorsController extends BaseController{
public $restful = true;
public function post_document_details($name,$path)
{
$document_details=Response::json(Author::insert_document_details_Call());
return $document_details;
}
}
作者(模型):
class Author extends Eloquent {
public $table = 'document_details';
protected $primaryKey = 'id';
public static function insert_document_details_Call($name,$path)
{
return DB::select('call insert_document_details');
}
}
答案 0 :(得分:2)
第二个采用可以传递的参数列表
DB::select('call insert_document_details(?,?)',array($name,$path));
或
DB::statement('call insert_document_details(' . DB::raw($name) . ',' . DB::raw($path) . ')');