1. Go to this page and download the library: Download ojenra/laravel-sproc library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ojenra / laravel-sproc example snippets
use Masterei\Sproc\Facades\SP;
/**
* Use this method if you are not expecting any dataset result.
* @return void
*/
SP::call('stored_procedure_name')
->params([
'Param01' => 'Arg01',
'Param02' => 'Arg02',
])
->execute();
/**
* Standard way of retrieving data from stored procedure.
* This method accepts a dataset index. The default index is 0.
*/
SP::call('stored_procedure_name')
->params([
'Param01' => 'Arg01',
'Param02' => 'Arg02',
])
->get();
/**
* Returns first object from an object array.
*/
SP::call('stored_procedure_name')
->params([
'Param01' => 'Arg01',
'Param02' => 'Arg02',
])
->first();
/**
* Retrieves all dataset result.
* Can be chained with first() method.
*/
SP::call('stored_procedure_name')
->params([
'Param01' => 'Arg01',
'Param02' => 'Arg02',
])
->all();
/**
* Use this method to initialize dataset results.
* Can be chained with first(), get() or all() method.
*/
$sp = SP::call('stored_procedure_name')
->params([
'Param01' => 'Arg01',
'Param02' => 'Arg02',
])
->fetch();
// example
$data01 = $sp->get(1);
$data02 = $sp->get(2);
/**
* Returns id, ID or first row result generated by the stored procedure.
*/
SP::call('stored_procedure_name')
->params([
'Param01' => 'Arg01',
'Param02' => 'Arg02',
])
->getScopeID();
/**
* Use this method to view generated raw query string.
*/
SP::call('stored_procedure_name')
->params([
'Param01' => 'Arg01',
'Param02' => 'Arg02',
])
->toSql();
/**
* Convert plain arrays into collection of models.
* Can be chained with first(), get() or all() method.
*/
SP::hydrate([
"key01" => "value01",
"key02" => "value02"
]);