繁体   English   中英

在Laravel 5中何处以及如何创建存储过程

[英]Where and how to create a stored procedure in Laravel 5

我正在为我的项目使用laravel 5.1,直到现在我们才完善,直到我想在其中使用存储过程。

到目前为止,我已收集到的信息为

 $result = DB::select('call InsertNewApplicant(?????????????????????????)',
                    array($firstName, $middleName, $addressLine_1, $addressLine_2, $postCode, $landline, $mobile, $email,
                    $DOB, $maritalStatus, $industry, $occupation, $jobTitle, $selfEmployed, $selfAssessment, $workHome,
                    $ownTransport, $companyVehicle, $paySubs, $otherIncome, $printForms, $marketingUs, $marketingOther,
                    $agreedTNCs, $TNCVersion, $CampaignSource));

可能正在使用此代码让控制器更新来自mysql的任何数据,但作为Laravel的初学者,我不知道在哪里定义我的存储过程以及在哪个文件中

我访问了很多链接,但我能得到的只是这段代码,而不是一个完美的例子。

您能否详细说明如何在控制器中调用存储过程以执行特定操作?

以及必须要处理的先决条件和其他事项

哇哇哇 您正在使用Laravel,因此请不要编写类似的代码。 这是一种罪过!

请阅读Laravel快速入门指南中的以下示例: https //laravel.com/docs/5.2/quickstart#eloquent-models https://laravel.com/docs/5.2/quickstart#creating-the-task

第一个是关于雄辩模型(你现在应该使用),第二个显示了如何使用存储这些模型数据库中的数据。


现在开始手头的任务。 我认为使用

DB::statement(DB::raw("CALL InsertNewApplicant('$firstName', '$middleName');"));

等等,应该这样做......

是。 把它放进一个控制器,并保持这种方式,直到你想改变一些东西。 你可以将它抽象出可能被嘲笑的专用类。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM