Reputation: 5107
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?
Upvotes: 2
Views: 1084
Reputation: 4135
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()
.
Upvotes: 2