PDO loop for updating multiple rows
UPDATE website
SET http_code = CASE id_website
WHEN 1 THEN 200
WHEN 2 THEN 201
WHEN 3 THEN 202
END,
link_exists = CASE id_website
| var url = 'http://sample.com' | |
| var ws = new WebSocket(url); | |
| var msg = "hi, this is simple message."; | |
| ws.onopen = function(evt) { | |
| ws.send(msg); | |
| }; | |
| ws.onmessage = function(evt) { | |
| // handle this message | |
| console.log(evt.data); | |
| }; |
| // Fastest way to move first element to the end of an Array | |
| var array = [8,1,2,3,4,5,6,7]; | |
| array.push(array.shift()); // results in [1, 2, 3, 4, 5, 6, 7, 8] | |
| // https://stackoverflow.com/a/20385895/2618535 |
| // jQuery Add Class, Delay, Remove Class | |
| $('.animated-selector').addClass('hidden').stop().delay(500).queue(function(){ | |
| $(this).removeClass('hidden'); | |
| }); | |
| // https://gist.github.com/randyjensen/6223653 |
PDO loop for updating multiple rows
UPDATE website
SET http_code = CASE id_website
WHEN 1 THEN 200
WHEN 2 THEN 201
WHEN 3 THEN 202
END,
link_exists = CASE id_website
Create tmp file from string
$string = 'random string';
$file = tempnam(sys_get_temp_dir(), 'POST');
file_put_contents($file, $string);
polyfill for curl_file_create
if (!function_exists('curl_file_create')) {
function curl_file_create($filename, $mimetype = '', $postname = '') {
return "@$filename;filename="
. ($postname ?: basename($filename))
. ($mimetype ? ";type=$mimetype" : '');
}
}
How to json_encode array with cyrilic accents?
// преобразование utf8 в cp1251
$current_charset = 'windows-1251';
array_walk_recursive($m_post, function(&$value) use ($current_charset) {
$value = iconv($current_charset, 'UTF-8', $value);
});
$str_post = array('str_post' => json_encode($m_post));
echo "this is the body" | mail -s "this is the subject" "to@address"
PHP json_encode encoding numbers as strings
$arr = array( 'row_id' => '1', 'name' => 'George' );
echo json_encode( $arr, JSON_NUMERIC_CHECK ); // {"row_id":1,"name":"George"}