[PHP]unzip
public function unzip($file,$to) { $zip = new ZipArchive(); $result = $zip->open($file); if($result === true){ $result = $zip->extractTo($to); $zip->close(); } return $result === true; }
public function unzip($file,$to) { $zip = new ZipArchive(); $result = $zip->open($file); if($result === true){ $result = $zip->extractTo($to); $zip->close(); } return $result === true; }
REGEXPはマルチバイトに対応していないので、FIND_IN_SETを使用。
INSERT INTO xxx(initial_chara,gyo) ( SELECT SUBSTRING(tmp.name,1,1), (CASE WHEN FIND_IN_SET(SUBSTRING(tmp.name,1,1),'あ,い,う,え,お') THEN 'あ' WHEN FIND_IN_SET(SUBSTRING(tmp.name,1,1),'か,き,く,け,こ,が,ぎ,ぐ,げ,ご') THEN 'か' WHEN FIND_IN_SET(SUBSTRING(tmp.name,1,1),'さ,し,す,せ,そ,ざ,じ,ず,ぜ,ぞ') THEN 'さ' WHEN FIND_IN_SET(SUBSTRING(tmp.name,1,1),'た,ち,つ,て,と,だ,ぢ,づ,で,ど') THEN 'た' WHEN FIND_IN_SET(SUBSTRING(tmp.name,1,1),'な,に,ぬ,ね,の') THEN 'な' WHEN FIND_IN_SET(SUBSTRING(tmp.name,1,1),'は,ひ,ふ,へ,ほ,ば,び,ぶ,べ,ぼ') THEN 'は' WHEN FIND_IN_SET(SUBSTRING(tmp.name,1,1),'ま,み,む,め,も') THEN 'ま' WHEN FIND_IN_SET(SUBSTRING(tmp.name,1,1),'や,ゐ,ゆ,ゑ,よ') THEN 'や' WHEN FIND_IN_SET(SUBSTRING(tmp.name,1,1),'ら,り,る,れ,ろ') THEN 'ら' WHEN FIND_IN_SET(SUBSTRING(tmp.name,1,1),'わ,を,ん') THEN 'わ' ELSE 'ん' END ) FROM yyy AS tmp
$this->db->list_tables();
上記だとキャッシュから取得する。キャッシュを回避する場合下記を使用。
public function get_table_names_by_dbname($dbname) { $names = array(); $sql = "SHOW TABLES FROM {$dbname}"; $query = $this->db->query($sql); foreach ($query->result_array() as $row) { if ( ! isset($key)) { if (isset($row['table_name'])) { $key = 'table_name'; } elseif (isset($row['TABLE_NAME'])) { $key = 'TABLE_NAME'; } else { $key = array_keys($row); $key = array_shift($key); } } $names[] = $row[$key]; } return $names; }
$this->output->set_header('X-Frame-Options: SAMEORIGIN'); $this->output->set_header('Cache-control: no-cache, no-store, post-check=0, pre-check=0'); $this->output->set_header('Pragma: no-cache'); $this->output->set_header('Expires: Thu, 01 Dec 1994 16:00:00 GMT');
AmazonRDSは仕様上FILE権限は付与出来ない。
故に
LOAD DATA INFILE xxxx.csv INTO TABLE wp_names FIELDS TERMINATED BY ',' ENCLOSED BY '\"' IGNORE 1 LINES;
を
LOAD DATA LOCAL INFILE xxxx.csv INTO TABLE wp_names FIELDS TERMINATED BY ',' ENCLOSED BY '\"' IGNORE 1 LINES;
へ変更するとよい
※余談
windows上ではパスのセパレータを/に変換しないと動かないことも
$filepath = preg_replace('/\\\\/','/',$filepath);
functions.php
function my_shortcode($attr) { $tmp = isset($_GET[$attr[0]]) ? (is_array($_GET[$attr[0]]) ? implode(',',$_GET[$attr[0]]) : $_GET[$attr[0]]) : ""; return esc_html($tmp); } add_shortcode('getq', 'my_shortcode');
GETクエリxxxの値を出力
[getq xxx]
function echo_json($data) { header("Content-Type: application/json; charset=utf-8"); echo json_encode($data); }
public function is_https() { if(!empty($_SERVER["HTTPS"])) return true; //AWS if(!empty($_SERVER["HTTP_X_FORWARDED_PROTO"]) && strtolower($_SERVER["HTTP_X_FORWARDED_PROTO"])==="https") return true; return false; }