Skip to content

Instantly share code, notes, and snippets.

@fhferreira
Last active December 17, 2015 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save fhferreira/5643409 to your computer and use it in GitHub Desktop.
Save fhferreira/5643409 to your computer and use it in GitHub Desktop.
Usage Procedure with Laravel.
<?php
class MysqliConn{
/**
* @return Instance of Mysqli $mysqli
* @author Flávio Henrique Ferreira <flaviometalvale@gmail.com>
**/
public static function conecta(){
/*
* Config sets in the app/config/database.php
*/
$connection = Config::get('database.connections.mysql');
$host = $connection['host'];
$database = $connection['database'];
$username = $connection['username'];
$password = $connection['password'];
$mysqli = new mysqli($host, $username, $password, $database);
return $mysqli;
}
/**
* @return result of call/execute to $sql
**/
public static function executaProcedure($sql){
$mysqli = self::conecta();
return $mysqli->query( $sql );
}
}
/* Usage */
$sql = "call updateProfiles();";
$result = MysqliConn::executaProcedure($sql);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment