Using a stored procedure in Laravel 4

后端 未结 2 1273
长发绾君心
长发绾君心 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: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());
    

提交回复
热议问题