Created
October 3, 2015 03:57
-
-
Save lukesUbuntu/58171f3a3babfc8735f2 to your computer and use it in GitHub Desktop.
query url call example for possible sql
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 | |
/** | |
* Created by PhpStorm. | |
* User: 9901623 | |
* Date: 3/10/2015 | |
* Time: 4:32 PM | |
*/ | |
//words | |
//basic query call | |
$url = "&img_src&desc&limit=10&random"; | |
//specify in_array security what calls above can be made | |
//parse to our search array | |
$searchFlag = array(); | |
$flags = array(); | |
//parse it | |
parse_str($url,$searchFlag); | |
//debug $search Array ( [img_src] => [desc] => [limit] => 10 ) | |
//any manual flag not for search goes here | |
//kill limit if passed | |
if (isset($searchFlag['limit'])){ | |
//word limit | |
unset($searchFlag['limit']); | |
} | |
if (isset($searchFlag['random'])){ | |
//randomise wordlise | |
unset($searchFlag['random']); | |
} | |
//unique flags | |
foreach($searchFlag as $key => $value) | |
$flags[] = $key; | |
//array map | |
$search = array_map("addAnd", $flags); | |
//implode into our query | |
$query = implode(' & ', $search); | |
//print out query | |
print_r($query); | |
function addAnd($n) | |
{ | |
return($n.' != ""'); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment