Last active
December 17, 2015 17:08
-
-
Save fhferreira/5643409 to your computer and use it in GitHub Desktop.
Usage Procedure with Laravel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MysqliConn{ | |
/** | |
* @return Instance of Mysqli $mysqli | |
* @author Flávio Henrique Ferreira <[email protected]> | |
**/ | |
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