Using a stored procedure in Laravel 4

后端 未结 2 1286
长发绾君心
长发绾君心 2021-01-03 02:38

I\'m trying to call a stored procedure from via a laravel route and i keep getting an error:

{\"error\":{\"type\":\"Illuminate\\\\Database\\\\QueryException\         


        
相关标签:
2条回答
  • 2021-01-03 03:25

    Found out a way to get this working here:

    $result = DB::select('call getLibraryList(?)',array($email));
    
    0 讨论(0)
  • 2021-01-03 03:32

    You might find some trouble to execute them. Here are some options:

    DB::statement(DB::raw('CALL getLibraryList('.$email.');'));
    

    Or

    DB::select('CALL getLibraryList(?)',array($email));
    

    And, the dirtiest one:

    $db = DB::connection();
    
    $stmt = $db->pdo->prepare("CALL getLibraryList(?)");
    
    $stmt->bindParam(1, $email);
    $stmt->execute();
    
    $search = array();
    
    do {
        $search = $stmt->fetchAll(PDO::FETCH_CLASS, 'stdClass');
    } while ($stmt->nextRowset());
    
    0 讨论(0)
提交回复
热议问题