public function remove_insert() { // -- detele table first before inserting -- // $this->tempdb_sql->query(remove_all()); // -- in $ci =& get_instance(); $ci->load->model('webapps/treqiss_hdr_model'); }
function remove_all($dir) { $res = opendir($dir); if (!$res) { return false; } while (($file = readdir($res)) !== false) { if ($file !== '.' && $file !== '..') { $str = $dir . '/' . $file; if (is_dir($str)) { remove_all($str); @rmdir($str); } else { @unlink($str); } } } closedir($res); }
function standardize_code($str) { # removing newlines $str = remove_all("\n", $str); $str = remove_all("\r", $str); # removing tabs $str = remove_all(' ', $str); # removing multiple spaces $str = remove_all(' ', $str); $str = remove_all(' ', $str); # removing empty lines $str = remove_all(" \r", $str); # removing starting spaces $str = str_replace("\r ", "\r", $str); # standardize curly braces $str = str_replace(' {', "{", $str); $str = str_replace('{ \\r', "{", $str); $str = str_replace('{ ', "{", $str); $str = str_replace(' }', "\r}", $str); $str = str_replace("}\r\r", "}\r", $str); # standardize colons $str = str_replace(' :', ":", $str); $str = str_replace(': ', ":", $str); # replace multiple returns $str = str_replace("\r\r\r", "\r", $str); $str = str_replace("\r\r", "\r", $str); $str = str_replace(";\r\r", ";\r", $str); # move each declaration to one line $str = str_replace("{\r", "{", $str); $str = str_replace(";\r", ";", $str); $str = str_replace("\r}", "}", $str); # removing returns $str = remove_all("\r", $str); # return the string return $str; }