Skip to content

Instantly share code, notes, and snippets.

View tanrax's full-sized avatar

Andros Fenollosa tanrax

View GitHub Profile
@tanrax
tanrax / gist:8931246
Created February 11, 2014 08:38
SQL: Consultas (SELECT)
<?php
/* Simple */
SELECT columnas FROM tablas WHERE filtro;
SELECT * FROM vecinos;
SELECT * FROM vecinos WHERE perro = '1';
/* Contar número de resultados */
SELECT count(*) FROM vecinos;
@tanrax
tanrax / gist:8870919
Created February 7, 2014 20:18
JQuery: Plantilla (básico)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
</head>
<body>
<div id="miId">Lorem ipsum dolor sit amet.</div>
@tanrax
tanrax / gist:8742855
Created January 31, 2014 20:50
PHP: Clase abstracta (sbstract)
<?php
/** Clase abstracta **/
abstract class Remolque
{
//Fuerza la extensión de clase para definir estos métodos
abstract public function enganchar();
abstract public function soltar();
@tanrax
tanrax / gist:8735778
Created January 31, 2014 16:38
PHP: Variable salto de línea
PHP_EOL
@tanrax
tanrax / gist:8735408
Created January 31, 2014 16:20
PHP: Constante static (estatica)
<?php
public static $NOMBRE = 'Los manicos';
echo Panaderia::$NOMBRE;
?>
@tanrax
tanrax / gist:8734400
Created January 31, 2014 15:38
PHP: Autocargador de bibliotecas (librerias)
<?php
/** Autocargador de librerias **/
spl_autoload_register('autocargador');
function autocargador($insNom)
{
include $insNom . '.class.php';
}
@tanrax
tanrax / gist:8694735
Created January 29, 2014 19:10
PHP: Enviar array con POST
<?php
$aPaises = array();
$aPaises[] = 'Chile';
$aPaises[] = 'Nigeria';
$aPaises[] = 'Ecuador';
?>
@tanrax
tanrax / gist:8650942
Created January 27, 2014 15:48
PHP: Comprobar datos POST
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST') {
}
?>
@tanrax
tanrax / gist:8580622
Created January 23, 2014 15:34
PHP: Comprobar datos GET
$_SERVER['REQUEST_METHOD'] == 'GET'
@tanrax
tanrax / gist:8458356
Created January 16, 2014 16:43
PHP: Ejemplo bucles
<?php
//For
for ($i = 0; $i < 5; $i++) {
echo $i;
}
//While
$iNum = 0;
while ($iNum <= 10) {