function ob_callback($buffer) {
global $ob_file;
fwrite($ob_file, $buffer);
}
$ob_file = fopen('test.txt','w');
ob_start("ob_callback");
/* Here goes content. */
ob_end_flush();
Saturday, May 29, 2010
Sunday, May 16, 2010
Thursday, May 13, 2010
Copying selected record from one MySQL table to another
In the case of existing table with the same structure:
INSERT table2 SELECT * FROM table1 WHERE [conditions]
Alternative syntax for a table with different structure:
INSERT table2 (columnA, columnB) SELECT column1, column2 FROM table1 WHERE [conditions]
INSERT table2 SELECT * FROM table1 WHERE [conditions]
Alternative syntax for a table with different structure:
INSERT table2 (columnA, columnB) SELECT column1, column2 FROM table1 WHERE [conditions]
Saturday, May 8, 2010
print_r() output to a file
ob_start();
print_r($array);
$output = ob_get_clean();
file_put_contents("log.txt", $output);
print_r($array);
$output = ob_get_clean();
file_put_contents("log.txt", $output);
Saturday, May 1, 2010
MySQL random integer in the range
To obtain a random integer R in the range i <= R < j, use the expression FLOOR(i + RAND() * (j – i)).
Subscribe to:
Posts (Atom)