This file contains hidden or 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
DELETE FROM table1 | |
USING table1, table1 as vtable | |
WHERE (NOT table1.ID=vtable.ID) | |
AND (table1.field_name=vtable.field_name) |
This file contains hidden or 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
/** | |
anonymous function to init graph | |
*/ | |
function callAjax(controller, method, params) { | |
return $.ajax({ | |
url: '/th_ci/' + controller + '/' + method + '/' + params, | |
type: 'POST', | |
dataType: 'json', | |
success: function(data){} | |
}); |
This file contains hidden or 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
var PopURL = 'http://www.google.com'; | |
var PopWidth = 1100; | |
var PopHeight = 700; | |
var PopCookieTimeout = 3600; | |
// TH - Popper Date 6-28-2012 | |
// | |
var P = false; | |
var W = 0; | |
var B = null; |
This file contains hidden or 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 | |
function toCSV(array $data, array $colHeaders = array(), $asString = false) { | |
$stream = ($asString) | |
? fopen("php://temp/maxmemory", "w+") | |
: fopen("php://output", "w"); | |
if (!empty($colHeaders)) { | |
fputcsv($stream, $colHeaders); | |
} |
This file contains hidden or 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 | |
spl_autoload_register(function ($classname) { | |
$classname = ltrim($classname, "\\"); | |
preg_match('/^(.+)?([^\\\\]+)$/U', $classname, $match); | |
$classname = str_replace("\\", "/", $match[1]) | |
. str_replace(["\\", "_"], "/", $match[2]) | |
. ".php"; | |
include_once $classname; | |
}); |
This file contains hidden or 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 | |
//template.class.php | |
class Template | |
{ | |
protected $dir; | |
protected $vars; | |
public function __construct($dir = "") { | |
$this->dir = (substr($dir, -1) == "/") ? $dir : $dir . "/"; | |
$this->vars = array(); |
This file contains hidden or 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 | |
$html = file_get_contents("http://example.com/product/42"); | |
$context = stream_context_create(array( | |
"http" => array( | |
"method" => "POST", | |
"header" => "Content-Type: multipart/form-data; boundary=--foo\r\n", | |
"content" => "--foo\r\n" | |
. "Content-Disposition: form-data; name=\"myFile\"; filename=\"image.jpg\"\r\n" | |
. "Content-Type: image/jpeg\r\n\r\n" |
This file contains hidden or 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 | |
// Check Range of Value | |
$value = filter_input(INPUT_GET, "value", FILTER_VALIDATE_INT, | |
array("options" => array("min_range" => 15, "max_range" => 20))); | |
if ($value) { | |
// run my code | |
} | |
else { | |
// handle the issue | |
} |
This file contains hidden or 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 | |
// an array (using PHP 5.4's new shorthand notation) | |
$arr = ["sitepoint", "phpmaster", "buildmobile", "rubysource", | |
"designfestival", "cloudspring"]; | |
// create a new ArrayIterator and pass in the array | |
$iter = new ArrayIterator($arr); | |
// loop through the object | |
foreach ($iter as $key => $value) { |
This file contains hidden or 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 | |
// a multidimensional array | |
$arr = [ | |
["sitepoint", "phpmaster"], | |
["buildmobile", "rubysource"], | |
["designfestival", "cloudspring"], | |
"not an array" | |
]; | |
// loop through the object |