Created
February 20, 2013 09:03
-
-
Save josuebasurto/e64ad12c6273ef248c70 to your computer and use it in GitHub Desktop.
Consulta Generica en PHP
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
/* Copyright Josue Basurto 2013 | @josuebasurto | http://josuebasurto.com */ | |
/* Este script tiene fallas no fue probado solo fue usado para demostracion de algoritmo de flexibilidad de campos y hace falta pruebas anti-SQLI */ | |
$consulta_alumno = "SELECT * FROM tbl_alumno "; | |
define('K_WHERE', ' where '); | |
function busqueda_alumno(string campo, string filtros, ) | |
{ | |
if (campos='') | |
return $consulta_alumno; | |
else | |
return $consulta_alumno.K_WHERE.campo.' = '.filtro; | |
} | |
//y asi lo puedes usar asi: | |
mysql_query(busqueda_alumno('nombre', '\'josue\'')); | |
mysql_query(busqueda_alumno('edad', '30')); | |
mysql_query(busqueda_alumno('calle', '\'jazmin\'')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment