How do I execute a procedure in laravel?

1

What kind of friends do I come to ask for your help, I am working on laravel 5.4 for some issues I have to execute a stored procedure that performs an insert and returns the id of the saved record, my question is how do I receive the id that returns the procedure after the insert so far only returns me true or false, it is worth mentioning that the database is in mysql.

    $id = 'roman';
    $pw = '9141186427';
    $cod = '0';
    $db = DB::connection();
    $db = new PDO('mysql:host=localhost;dbname=servicios', "root", "");
    $sql = $db->prepare('CALL insert_cliente ?, ?, ?');
    $sql->bindParam(1, $id);
    $sql->bindParam(2, $pw);
    $sql->bindParam(3, $cod);
    $sql->execute();
    
asked by roman madrigal 20.10.2017 в 06:17
source

1 answer

1

Try as follows:

DB::select('CALL insert_cliente ?, ?, ?',array($id,$pw,$cod));

or

DB::statement('CALL insert_cliente ?, ?, ?',array($id,$pw,$cod));

Greetings.

    
answered by 20.10.2017 в 16:08