Skip to content

Instantly share code, notes, and snippets.

@einnar82
Created October 8, 2019 09:36
Show Gist options
  • Save einnar82/bc8c59d27a8de5b0005c74d0f3468a2d to your computer and use it in GitHub Desktop.
Save einnar82/bc8c59d27a8de5b0005c74d0f3468a2d to your computer and use it in GitHub Desktop.
Stored Procedure PHP
<?php
namespace App\Http\Controllers;
use App\Model\Notification;
use App\Abstracts\Controllers\ApiController;
use Doctrine\DBAL\Driver\PDOConnection;
use Illuminate\Http\Request;
class StoredProcController extends ApiController
{
public function start(Request $request) {
$db = \DB::connection()->getPdo();
$db->setAttribute(PDOConnection::ATTR_ERRMODE, PDOConnection::ERRMODE_EXCEPTION);
$db->setAttribute(PDOConnection::ATTR_EMULATE_PREPARES, true);
$res = $db->prepare('CALL getAllNotifications()');
$res->execute();
$data = $res->fetchAll(PDOConnection::FETCH_ASSOC);
$res->closeCursor();
return $data;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment