ojenra / laravel-sproc
This package is abandoned and no longer maintained.
The author suggests using the masterei/laravel-sproc package instead.
Laravel Query Builder for handling stored procedure.
v3.0.2
2023-12-07 02:05 UTC
Requires
- php: ^7.3|^8.0
- ext-pdo: *
Requires (Dev)
- orchestra/testbench: ^7.6
README
Laravel Query Builder for handling stored procedure.
Installation
You can install the package via composer:
composer require masterei/laravel-sproc
Optionally, you can publish the config file with:
php artisan vendor:publish --tag="sproc-config"
Usage
Import class facade
use Masterei\Sproc\Facades\SP;
execute()
/** * Use this method if you are not expecting any dataset result. * @return void */ SP::call('stored_procedure_name') ->params([ 'Param01' => 'Arg01', 'Param02' => 'Arg02', ]) ->execute();
get()
/** * 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();
first()
/** * Returns first object from an object array. */ SP::call('stored_procedure_name') ->params([ 'Param01' => 'Arg01', 'Param02' => 'Arg02', ]) ->first();
all()
/** * Retrieves all dataset result. * Can be chained with first() method. */ SP::call('stored_procedure_name') ->params([ 'Param01' => 'Arg01', 'Param02' => 'Arg02', ]) ->all();
fetch()
/** * 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);
getScopeID()
/** * Returns id, ID or first row result generated by the stored procedure. */ SP::call('stored_procedure_name') ->params([ 'Param01' => 'Arg01', 'Param02' => 'Arg02', ]) ->getScopeID();
toSql()
/** * Use this method to view generated raw query string. */ SP::call('stored_procedure_name') ->params([ 'Param01' => 'Arg01', 'Param02' => 'Arg02', ]) ->toSql();
hydrate()
/** * Convert plain arrays into collection of models. * Can be chained with first(), get() or all() method. */ SP::hydrate([ "key01" => "value01", "key02" => "value02" ]);
Note
- This package uses Laravel Eloquent Collection meaning that you can freely use its features like groupBy(), sortBy(), map() etc.
Changelog
Please see CHANGELOG for more information on what has changed recently.
License
The MIT License (MIT). Please see License File for more information.