samedi 30 janvier 2016

Laravel 5 - Cannot find MySQL Stored Procedure

ISSUE: Converting my L4 code to L5.2 and am receiving the following error: SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION cr_debug.ENTER_MODULE2 does not exist (SQL: call POPULATE_DAYS_TABLE(20, "01/29/2016")) & SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION cr_debug.ENTER_MODULE2 does not exist

ATTEMPTED: I have searched Stackoverflow and Google to find what is happening. I have attempted to change call to EXEC and that created another error stating that my version of MySQL doesn't support call. I just installed the latest version MySQL two weeks ago. I have tried to namespace the procedure call to no avail. I have removed all spaces from function calls within the Stored Procedure (Example: IF (var) is now IF(var) or function (var) is now function(var).

REQUEST: Please assist in helping figure out what is wrong and explain in detail what I am doing wrong with examples, if possible.

NOTES: I have severely shortened the ContractController.php file for brevity. If you need to see the stored procedures I can display those too. The stored procedures are in MySQL. This works in Laravel 4.

DEBUG INFORMATION: ERROR 1 OF 2 PDOException in Connection.php line 390: SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION cr_debug.ENTER_MODULE2 does not exist

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 QueryException in Connection.php line 651: SQLSTATE[42000]: Syntax error or access violation: 1305 FUNCTION cr_debug.ENTER_MODULE2 does not exist (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();
  }



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1Ki7IQa
via IFTTT

Aucun commentaire:

Enregistrer un commentaire