Skip to content

Instantly share code, notes, and snippets.

@juanwilde
Created December 21, 2015 13:52
Show Gist options
  • Save juanwilde/fa56512dfe8e6e8e1896 to your computer and use it in GitHub Desktop.
Save juanwilde/fa56512dfe8e6e8e1896 to your computer and use it in GitHub Desktop.
Patrón MVC básico
protected function getSql($key)
{
if (isset($_POST[$key]) && !empty($_POST[$key])) {
$_POST[$key] = strip_tags($_POST[$key]);
if (!get_magic_quotes_gpc()) {
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
if ($mysqli->connect_error) {
die('Connection error (' . $mysqli->connect_errno . ') '
. $mysqli->connect_error);
} else {
$_POST[$key] = $mysqli->real_escape_string($_POST[$key]);
}
}
return trim($_POST[$key]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment