Skip to content

Instantly share code, notes, and snippets.

@phpfiddle
Created April 4, 2017 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phpfiddle/a34ff7879c1c2200f42d87ed4292d96f to your computer and use it in GitHub Desktop.
Save phpfiddle/a34ff7879c1c2200f42d87ed4292d96f to your computer and use it in GitHub Desktop.
[ Posted by Silentrunning ] dfgsdfgsdgfsdfgsdfgsdgfsdgsdfgsdfgd
<?php
class Ejemplo{
public $color="";
public $altura=0;
/*public void __set ($nombre, $valor){
switch($nombre){
case "color":
if (preg_match("/^#[0-9A-F]{6}$/",$valor)){
}
$this->color=$valor;
break;
case "altura":
throw("Esta propiedad es de solo lectura");
break;
}
}*/
}
// mejor con try catch
$conBBDD=@new mysqli("localhost","usuario","123456","neptuno");// la arroba evita que haga echo cualquier comando con errores
required_once("inc/config.php");//aqui definimos los parametros de la conexion
if ($conBBDD->connect_errno){
echo "no se puedo conectar con la BBDD intentelo dentro de un rato";
}
$rscDatos=$conBBDD->query("SELECT * FROM TABLA");// lo normal es que metamos un procedimiento almacenado no una consulta ("call nombreProcedimiento();")
///
echo $rscDatos->num_rows;
while($oFila=$rscDatos->fetch_object()){
echo $oFila->Login."</br>";
}
class Neptuno{
private $conBBDD;
public function __construct($host,$user,$password){
if(!(filter_var($host,FILTER_VALIDATE_IP) || preg_match ("/^[A-Z0-9]+(\.[A-Z0-9]+)*$/",$host))){
throw new Exception("url incorrecta");
}
}
public function __destruct(){
$this->conBBDD->close();
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment