2

In Laravel, I currently have a working function that accepts arguments, uses them in a stored procedure, and then creates a variable from the output of the procedure to be used in another function call. The variable in question is $out2, and when the process is successful, it calls the function createUser with that variable.

function createMainUser($firstName,$lastName){

    $stmt = \DB::connection('odbc')->getPdo()->prepare('CALL procedure.create_user(?,?,?)'); 

    $stmt->bindParam(1, $firstName, PDO::PARAM_STR);
    $stmt->bindParam(2, $lastName, PDO::PARAM_STR);
    $stmt->bindParam(3, $out2, PDO::PARAM_STR);

    $stmt->execute();

    return $this->createUser($out2,$firstName,$lastName);

}

Everything here works perfectly. However, I'm wondering if I can call multiple functions with that $out2 variable. So when createMainuser runs and is successful, thus creating $out2 I'd like to keep doing what I'm doing now with the return, but I'd also like to call a function called tempUserRecord with $out2.

Is that something I can adequately do?

1 Answer 1

2

Maybe I'm understanding your question wrongly, but this seems rather easy?

$userCreated = $this->createUser($out2,$firstName,$lastName);

if ($userCreated) {  // Depends on what "createUser" returns
    $this->tempUserRecord($out2); // Might not be "$this"
}

return $userCreated;

Or run tempUserRecords() in the function where you call createMainUser().

Sign up to request clarification or add additional context in comments.

1 Comment

I think your first portion there will work. The other option won't because I only get $out2 inside the createMainuser function. But that makes sense with the if statement, I think

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.