ISSUE:将我的L4代码转换为L5.2并收到以下错误:SQLSTATE [42000]:语法错误或访问冲突:1305功能cr_debug.ENTER_MODULE2不存在(SQL:call POPULATE_DAYS_TABLE(20,“01/29/2016”))& SQLSTATE [42000]:语法错误或访问冲突:1305功能cr_debug.ENTER_MODULE2不存在
UPDATE:我不知道函数cr_debug.ENTER_MODULE2是什么函数。我不知道那是什么来的。这似乎是导致问题的原因,因为MySQL中不存在该功能,也不知道它来自何处。在我的Laravel 5.2安装中使用Agent Ransack我只找到提示ENTER_MODULE2的日志文件,并在我的Laravel 4安装中为ENTER_MODULE2进行文本搜索我只找到了一个提到该文本的SQL Dump。该转储列在下面。 我确实在我的存储过程中找到了对ENTER_MODULE2的引用。检查出来并稍后回复。
SQL DUMP:
DECLARE cr_stack_depth INTEGER DEFAULT cr_debug.ENTER_MODULE2('FIRST_DAY', 'contracts', 8, 100430)/*[cr_debug.1]*/;
CALL cr_debug.UPDATE_WATCH3('`firstday`', `firstday`, 'DATE', cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.TRACE(4, 4, 0, 5, cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.TRACE(5, 5, 2, 67, cr_stack_depth)/*[cr_debug.2]*/;
SET @devart_debug_ret = ADDDATE(LAST_DAY(SUBDATE(firstday, INTERVAL 1 MONTH)), 1)/*[cr_debug.2]*/;
CALL cr_debug.LEAVE_MODULE(cr_stack_depth - 1)/*[cr_debug.2]*/;
RETURN @devart_debug_ret;
CALL cr_debug.TRACE(6, 6, 0, 3, cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.LEAVE_MODULE(cr_stack_depth - 1)/*[cr_debug.2]*/;
END ;;
DELIMITER ;
ATTEMPTED:我搜索了Stackoverflow和Google以查找正在发生的事情。我试图改变对EXEC的调用,并创建了另一个错误,指出我的MySQL版本不支持调用。我刚刚在两周前安装了MySQL的最新版本。我试图命名程序调用无效。我已经从存储过程中的函数调用中删除了所有空格(示例:IF(var)现在是IF(var)或函数(var)现在是函数(var)。我删除了存储过程并收到以下不同的错误: SQLSTATE [42000]:语法错误或访问冲突:1305 PROCEDURE contracts.POPULATE_DAYS_TABLE不存在(SQL:call POPULATE_DAYS_TABLE(29,“01/29/2016”))
请求:如果可能的话,请协助帮助弄清楚出了什么问题并详细解释我做错了什么。
注意:为简洁起见,我严重缩短了ContractController.php文件。如果您需要查看存储过程,我也可以显示它们。存储过程在MySQL中。这适用于Laravel 4。
调查信息: 错误1 of 2 Connection.php第390行中的 PDOException: SQLSTATE [42000]:语法错误或访问冲突:1305功能cr_debug.ENTER_MODULE2不存在
in Connection.php line 390
at PDOStatement->execute(array()) in Connection.php line 390
at Connection->Illuminate\Database\{closure}(object(MySqlConnection), 'call POPULATE_DAYS_TABLE(20, "01/29/2016")', array()) in Connection.php line 644
at Connection->runQueryCallback('call POPULATE_DAYS_TABLE(20, "01/29/2016")', array(), object(Closure)) in Connection.php line 611
at Connection->run('call POPULATE_DAYS_TABLE(20, "01/29/2016")', array(), object(Closure)) in Connection.php line 391
at Connection->statement('call POPULATE_DAYS_TABLE(20, "01/29/2016")')
at call_user_func_array(array(object(MySqlConnection), 'statement'), array('call POPULATE_DAYS_TABLE(20, "01/29/2016")')) in DatabaseManager.php line 317
at DatabaseManager->__call('statement', array('call POPULATE_DAYS_TABLE(20, "01/29/2016")')) in Facade.php line 218
at Facade::__callStatic('statement', array('call POPULATE_DAYS_TABLE(20, "01/29/2016")')) in computer.php line 15
at computer::storedProcedureCall('20', '01/29/2016') in ContractController.php line 56
at ContractController->store()
at call_user_func_array(array(object(ContractController), 'store'), array()) in Controller.php line 76
at Controller->callAction('store', array()) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(ContractController), object(Route), 'store') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(ContractController), object(Route), object(Request), 'store') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\ContractController', 'store') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 703
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 705
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 678
at Router->dispatchToRoute(object(Request)) in Router.php line 654
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 53
ERROR 2 OF 2 Connection.php第651行中的QueryException: SQLSTATE [42000]:语法错误或访问冲突:1305功能cr_debug.ENTER_MODULE2不存在(SQL:call POPULATE_DAYS_TABLE(20,“01/29/2016”))
in Connection.php line 651
at Connection->runQueryCallback('call POPULATE_DAYS_TABLE(20, "01/29/2016")', array(), object(Closure)) in Connection.php line 611
at Connection->run('call POPULATE_DAYS_TABLE(20, "01/29/2016")', array(), object(Closure)) in Connection.php line 391
at Connection->statement('call POPULATE_DAYS_TABLE(20, "01/29/2016")')
at call_user_func_array(array(object(MySqlConnection), 'statement'), array('call POPULATE_DAYS_TABLE(20, "01/29/2016")')) in DatabaseManager.php line 317
at DatabaseManager->__call('statement', array('call POPULATE_DAYS_TABLE(20, "01/29/2016")')) in Facade.php line 218
at Facade::__callStatic('statement', array('call POPULATE_DAYS_TABLE(20, "01/29/2016")')) in computer.php line 15
at computer::storedProcedureCall('20', '01/29/2016') in ContractController.php line 56
at ContractController->store()
at call_user_func_array(array(object(ContractController), 'store'), array()) in Controller.php line 76
at Controller->callAction('store', array()) in ControllerDispatcher.php line 146
at ControllerDispatcher->call(object(ContractController), object(Route), 'store') in ControllerDispatcher.php line 94
at ControllerDispatcher->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in ControllerDispatcher.php line 96
at ControllerDispatcher->callWithinStack(object(ContractController), object(Route), object(Request), 'store') in ControllerDispatcher.php line 54
at ControllerDispatcher->dispatch(object(Route), object(Request), 'App\Http\Controllers\ContractController', 'store') in Route.php line 174
at Route->runController(object(Request)) in Route.php line 140
at Route->run(object(Request)) in Router.php line 703
at Router->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Router.php line 705
at Router->runRouteWithinStack(object(Route), object(Request)) in Router.php line 678
at Router->dispatchToRoute(object(Request)) in Router.php line 654
at Router->dispatch(object(Request)) in Kernel.php line 246
at Kernel->Illuminate\Foundation\Http\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 52
at Pipeline->Illuminate\Routing\{closure}(object(Request)) in CheckForMaintenanceMode.php line 44
at CheckForMaintenanceMode->handle(object(Request), object(Closure))
at call_user_func_array(array(object(CheckForMaintenanceMode), 'handle'), array(object(Request), object(Closure))) in Pipeline.php line 124
at Pipeline->Illuminate\Pipeline\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 32
at Pipeline->Illuminate\Routing\{closure}(object(Request))
at call_user_func(object(Closure), object(Request)) in Pipeline.php line 102
at Pipeline->then(object(Closure)) in Kernel.php line 132
at Kernel->sendRequestThroughRouter(object(Request)) in Kernel.php line 99
at Kernel->handle(object(Request)) in index.php line 53
ContractController.php:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\Library\customer;
use App\Library\computer;
class ContractController extends Controller
{
Protected $layout = 'master';
public function store()
{
// Receive input from Form
$input = \Input::only([
'contractterm_id', 'businesstype_id', 'company', 'bcity', 'bphone', 'bstate', 'bstraddr',
'bzip', 'firstname', 'lastname', 'mobile', 'hcity',
'hphone', 'hstate', 'hstraddr', 'hzip'
]);
$morepcs_array = \Input::only('addtpcmake','addtpcmodel','addtpcserial','addtpcname');
/*
// Debugging Code
foreach ($morepcs_array as $textbox_name => $textbox)
{
echo "<br><br>".$textbox_name;
echo "<br>textbox quantity: ".sizeof($textbox);
foreach($textbox as $value) {
if ($value == NULL) {
echo "<br>NULL";
}
else {
echo "<br>".$value;
}
}
}
*/
$customer = new customer($input); // Create new customer object. Store $input into this object.
$computer = new computer; // Create new computer object
$computer->addtpcs = \Input::get('addtpcs'); // Get the form data for addtpcs and prepare to store it in a database table named addtpcs.
$computer->save(); // Save the information into the database table addtpcs from the computer object.
$customer->computer()->associate($computer); // Using the associate function, store the id from the computer table in the database to the customer_id table in the database.
$customer->save(); // send all of the data to the customer table in the database.
// $startdate = new day;
$startdate = \Input::get('contract_date');
// $customer->startdate()->save($startdate);
//Log::info('$startdate from controller before it is passed to the StoredProcedureCall method: ' . $startdate);
//Log::info('$customer->id from controller before it is passed to the StoredProcedureCall method: ' . $customer->id);
//Computer::storedProcedureCall($customer->id,$startdate);
//$days = Day::all()->last(); // Never do this. For testing purposes only.
// Figure out total contract cost based upon Contract Term and Business Type
computer::storedProcedureCall($customer->id,$startdate); // Call the MySQL stored procedure.
}
computer.php:
Class computer extends \Eloquent {
protected $guarded = array();
public function customer() {
return $this->hasMany('App\Library\customer');
}
public static function storedProcedureCall($customer, $contract_date) {
//Log::info('$contract_date after it is received from the controller: ' . $contract_date);
//Log::info('$data after it is received from the controller: ' . $data);
return \DB::statement('call POPULATE_DAYS_TABLE(' . $customer . ', "'.$contract_date.'")');
}
public static $rules = array();
}
错误日志:
[2016-01-31 16:36:20] local.ERROR: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION cr_debug.ENTER_MODULE2 does not exist in C:\Apache24\B2B_Contracts\vendor\laravel\framework\src\Illuminate\Database\Connection.php:390
Stack trace:
#0 C:\Apache24\B2B_Contracts\vendor\laravel\framework\src\Illuminate\Database\Connection.php(390): PDOStatement->execute(Array)
#1 C:\Apache24\B2B_Contracts\vendor\laravel\framework\src\Illuminate\Database\Connection.php(644): Illuminate\Database\Connection->Illuminate\Database\{closure}(Object(Illuminate\Database\MySqlConnection), 'call POPULATE_D...', Array)
#2 C:\Apache24\B2B_Contracts\vendor\laravel\framework\src\Illuminate\Database\Connection.php(611): Illuminate\Database\Connection->runQueryCallback('call POPULATE_D...', Array, Object(Closure))
#3 C:\Apache24\B2B_Contracts\vendor\laravel\framework\src\Illuminate\Database\Connection.php(391): Illuminate\Database\Connection->run('call POPULATE_D...', Array, Object(Closure))
#4 [internal function]: Illuminate\Database\Connection->statement('call POPULATE_D...')
更多错误 - 同一日志文件:
Next Illuminate\Database\QueryException: SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION cr_debug.ENTER_MODULE2 does not exist (SQL: call POPULATE_DAYS_TABLE(23, "01/29/2016")) in C:\Apache24\B2B_Contracts\vendor\laravel\framework\src\Illuminate\Database\Connection.php:651
Stack trace:
#0 C:\Apache24\B2B_Contracts\vendor\laravel\framework\src\Illuminate\Database\Connection.php(611): Illuminate\Database\Connection->runQueryCallback('call POPULATE_D...', Array, Object(Closure))
#1 C:\Apache24\B2B_Contracts\vendor\laravel\framework\src\Illuminate\Database\Connection.php(391): Illuminate\Database\Connection->run('call POPULATE_D...', Array, Object(Closure))
#2 [internal function]: Illuminate\Database\Connection->statement('call POPULATE_D...')
#3 C:\Apache24\B2B_Contracts\vendor\laravel\framework\src\Illuminate\Database\DatabaseManager.php(317): call_user_func_array(Array, Array)
答案 0 :(得分:2)
真的很奇怪但是不知怎的,MySQL创建了一堆添加到我的存储过程中的函数,导致它崩溃。
UPDATE 02/01/16: Shadow指出额外的调试来自dbforge studio,我确实下载了多年前调试存储过程。答案仍然是一样的。如果遇到此问题,请从备份还原,删除调试垃圾或重新安装调试软件。
这方面的一个例子是存储过程看起来像:
真实存储程序
BEGIN
SET contract_date = STR_TO_DATE(contract_date, '%m/%d/%Y'); /* Changes parameter sent it to an actual date */
SELECT DATE_FORMAT(contract_date, '%Y-%m-%d') INTO @start_date; /* Store proper date format for Contract End Dates */
修改后的MYSQL存储程序
BEGIN
DECLARE cr_stack_depth INTEGER DEFAULT cr_debug.ENTER_MODULE2('POPULATE_DAYS_TABLE', 'contracts', 7, 100430)/*[cr_debug.1]*/;
CALL cr_debug.UPDATE_WATCH3('`customer_id`', `customer_id`, 'INT', cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.UPDATE_WATCH3('`contract_date`', `contract_date`, 'TEXT', cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.TRACE(4, 4, 0, 5, cr_stack_depth)/*[cr_debug.2]*/;
CALL cr_debug.TRACE(5, 5, 0, 59, cr_stack_depth)/*[cr_debug.2]*/;
SET contract_date = STR_TO_DATE(contract_date, '%m/%d/%Y');
CALL cr_debug.UPDATE_WATCH3('contract_date', contract_date, '', cr_stack_depth)/*[cr_debug.1]*/; /* Changes parameter sent it to an actual date */
CALL cr_debug.TRACE(6, 6, 0, 63, cr_stack_depth)/*[cr_debug.2]*/;
SELECT DATE_FORMAT(contract_date, '%Y-%m-%d') INTO @start_date;
对此的解决方法是删除MySQL中的存储过程并从我拥有的备份中重新导入它们。如果您没有备份,则必须手动删除添加到它们的所有垃圾。
答案 1 :(得分:0)
由于对存储过程的调用很奇怪,您可以尝试将其传递到基础PDO对象,如..
$db = \DB::connection()->getPdo();
$stmt=$db->prepare($sql);
$stmt->bindParams($params);
$stmt->execute();
就像在原生PHP中一样。为简洁起见,但我希望你能得到这个想法