PostgreSQL[e_sqlstr()] ---------------------------------------------------------------------------*/ function sql_hard_bind($sql, $bind){ $lst = string_bind_list($sql); foreach($lst as $k => $v){ if(is_array($v)){ $b = $bind[$v["bind"]]; $lst[$k] = sql_data($b); } } return implode("", $lst); } function sql_data($dat) { if(is_array($dat)){ switch($dat["type"]){ case "date": $yyyy=fmt0000( utl_nvl($dat["y" ],1) ); $mm =fmt00 ( utl_nvl($dat["m" ],1) ); $dd =fmt00 ( utl_nvl($dat["d" ],1) ); $hh =fmt00 ( utl_nvl($dat["h" ],0) ); $mi =fmt00 ( utl_nvl($dat["mi"],0) ); $ss =fmt00 ( utl_nvl($dat["s" ],0) ); return "to_date('$yyyy-$mm-$dd $hh:$mi:$ss','yyyy-mm-dd hh24:mi:ss')"; default: return "'sql_data(type=".e_sqlstr($dat["type"]).")'"; } }else{ //START MOD 2007/09/10 Kishimoto 空はNULLに変換 // return "'".e_sqlstr($dat)."'"; return e_sqlstr_literal($dat); //END MOD 2007/09/10 Kishimoto 空はNULLに変換 } } function e_sqlstr_literal($s){ //START MOD 2007/09/10 Kishimoto 空はNULLに変換 // return "'".e_sqlstr($s)."'"; if($s === ""){ return "NULL"; }else{ return "'".e_sqlstr($s)."'"; } //END MOD 2007/09/10 Kishimoto 空はNULLに変換 } function e_sqlstr($s){ return e_sqlstr_postgreSQL($s); } // e_sqlstrと異なり、xd_sql_text()で生成したデータ(連想配列)の場合はエスケープせずに返す。 function e_sqlstr_unsafe($s){ if(xd_is_type($s,"sql")){ return xd_value($s); } else { return e_sqlstr($s); } } // sqlテキストを表す連想配列を返す function xd_sql_text($s){ return xd_make_data("sql", $s); } //実装。e_sqlstrから呼ばれる。直接呼ばないこと。 //-------------------------------------------- function e_sqlstr_oracle($s) { $s = str_replace("'", "''", $s); return $s; } function e_sqlstr_postgreSQL($s) { $s = str_replace("\\", "\\\\", $s); $s = str_replace("'", "\\'", $s); return $s; } ?>