$value ): array_push($new_insert,$key); //フィールド名配列を作成 array_push($new_value,$value ); //値配列を作成 endforeach; $sql.=" ( " . implode(",",$new_insert) . " ) values"; $sql.=" ( " . implode(",",$new_value) . " )"; return $sql; } ### upate function updateSql( $table,$update,$where ){ if( $where != "" ): $sql="update {$table} set "; //tableをつける //フィールド名 foreach ( $update as $key => $value ): $sql .= $key."=".$value; endforeach; $sql .= " where ".$where; else: print $table."にupdateができませんでした。"; exit; endif; return $sql; } ### delete function deleteSql( $table,$where ){ if($where !="" ): $sql="delete from {$table}"; $sql .= " where ".$where; else: print $table."にdeleteができませんでした。"; endif; return $sql; } //************************************************** // function iemoji_encode ( $str, $opt = true ) //************************************************** // 機 能:i-mode基本絵文字を10進数SJIS表記に、 // 拡張絵文字を16進数Unicode表記に変換する。 // 引 数:$str = i-mode絵文字を含む文字列 // $opt = falseを指定すると絵文字を削除する。 // 戻り値:変換(削除)後の文字列 //************************************************** function iemoji_encode( $str, $opt = true ) { $str = unpack("C*", $str); $len = count($str); $buff = ""; $n = 1; while($n <= $len) { $ch1 = $str[$n]; $ch2 = $str[$n+1]; if((($ch1 == 0xF8) && (0x9F <= $ch2) && ($ch2 <= 0xFC)) || (($ch1 == 0xF9) && ((0x40 <= $ch2) && ($ch2 <= 0x49) || (0x50 <= $ch2) && ($ch2 <= 0x52) || (0x55 <= $ch2) && ($ch2 <= 0x57) || (0x5B <= $ch2) && ($ch2 <= 0x5E) || (0x72 <= $ch2) && ($ch2 <= 0x7E) || (0x80 <= $ch2) && ($ch2 <= 0xB0)))) { if($opt) $buff .= '&#'.strval(($ch1 << 8) + $ch2).';'; $n++; } elseif(($ch1 == 0xF9) && (0xB1 <= $ch2) && ($ch2 <= 0xFC)) { if($opt) $buff .= '&#x'.strtoupper(dechex(0xE700 + $ch2 - 165)).';'; $n++; } // 2バイト文字の処理 elseif(((0x81 <= $ch1) && ($ch1 <= 0x9f) ) || ((0xe0 <= $ch1) && ($ch1 <= 0xfc))){ $buff .= pack("C", $ch1) . pack("C", $ch2); $n++; } else $buff .= pack("C", $ch1); $n++; } return $buff; } //************************************************** // function iemoji_decode ( $str ) //************************************************** // 機 能:i-mode基本絵文字10進数SJIS表記と、拡張絵文字 // 16進数Unicode表記を、元の2バイトコードに変換する。 // 引 数:$str = HTML表記コード化されたi-mode絵文字を含む文字列 // 戻り値:変換(削除)後の文字列 //************************************************** function iemoji_decode( $str ) { $str = preg_split("/&#([x0-9A-F]{5});/", $str, -1, PREG_SPLIT_DELIM_CAPTURE); $line = count($str); $buff = ""; $n = 0; while($n < $line) { if($n % 2) { if(preg_match("/^[0-9]{5}$/", $str[$n])) { $temp = intval($str[$n]); if((0xF89F <= $temp) && ($temp <= 0xF8FC) || (0xF940 <= $temp) && ($temp <= 0xF949) || (0xF950 <= $temp) && ($temp <= 0xF952) || (0xF955 <= $temp) && ($temp <= 0xF957) || (0xF95B <= $temp) && ($temp <= 0xF95E) || (0xF972 <= $temp) && ($temp <= 0xF97E) || (0xF980 <= $temp) && ($temp <= 0xF9B0)) $buff .= pack("C*", $temp >> 8, $temp % 256); else $buff .= $str[$n]; } elseif(preg_match("/^xE7(0[\x43-\x46]|[1-4][0-9A-F]|5[0-7])$/", $str[$n], $temp)) $buff .= pack("C*", 0xF9, hexdec($temp[1]) + 165); else $buff .= $str[$n]; } else $buff .= $str[$n]; $n++; } return $buff; } ?>mysqlDBConnect(); } ### 鴻紊ч緇 function getTopics($toId=""){ if($toId == ""){ $sql = "select * from yuai_topic where delflag=0 order by date desc "; }else{ $sql = "select * from yuai_topic where id=".$toId." and delflag=0 limit 1"; } $res = $this->getQuery($sql); return $res; } ### 緇宴茯莨若 function getOtokuinfo($toId=""){ if($toId == ""){ $sql = "select * from yuai_topic where type=1 and delflag=0 order by date desc "; }else{ $sql = "select * from yuai_topic where id=".$toId." and delflag=0 limit 1"; } $res = $this->getQuery($sql); return $res; } ### 亥宴茯莨若 function getTopicinfo($toId=""){ if($toId == ""){ $sql = "select * from yuai_topic where type=2 and delflag=0 order by date desc "; }else{ $sql = "select * from yuai_topic where id=".$toId." and delflag=0 limit 1"; } $res = $this->getQuery($sql); return $res; } ### 緇宴茵腓 function getOtokuinfoDisplay(){ $sql = "select * from yuai_topic where type=1 and display=1 and delflag=0 order by date desc "; $res = $this->getQuery($sql); return $res; } ### 亥宴茵腓 function getTopicinfoDisplay(){ $sql = "select * from yuai_topic where type=2 and display=1 and delflag=0 order by date desc "; $res = $this->getQuery($sql); return $res; } } ### insert model class Topic_Insert extends mysqlDBConnect{ function Topic_Insert(){ $this->mysqlDBConnect(); $this->column = array( 'type' => "'".$_REQUEST['type']."'" // ,'display' => "'".$_REQUEST['display']."'" ,'date' => "'".$_REQUEST['date']."'" ,'title' => "'".$_REQUEST['title']."'" ,'text' => "'".$_REQUEST['text']."'" ,'image' => "'".$_REQUEST['image']."'" ,'pdf' => "'".$_REQUEST['pdf']."'" ,'updated' => "'".date('Y-m-d H:i:s')."'" ); mysql_query( "begin" ); if( $this->putQuery( insertSql( "yuai_topic",$this->column ) ) ): mysql_query( "commit" ); endif; } } ### edit model class Topic_Edit extends mysqlDBConnect{ function Topic_Edit(){ $this->mysqlDBConnect(); /* $this->column = array( 'type' => "'".$_SESSION['SFT']['type']."'" ,',display' => "'".$_SESSION['SFT']['display']."'" ,',date' => "'".$_SESSION['SFT']['date']."'" ,',title' => "'".$_SESSION['SFT']['title']."'" ,',text' => "'".$_SESSION['SFT']['text']."'" ,',image' => "'".$_SESSION['SFT']['image']."'" ,',pdf' => "'".$_SESSION['SFT']['pdf']."'" ,',updated' => "'".date('Y-m-d H:i:s')."'" );*/ $this->column = array( 'type' => "'".$_REQUEST['type']."'" // ,',display' => "'".$_REQUEST['display']."'" ,',date' => "'".$_REQUEST['date']."'" ,',title' => "'".$_REQUEST['title']."'" ,',text' => "'".$_REQUEST['text']."'" ,',image' => "'".$_REQUEST['image']."'" ,',pdf' => "'".$_REQUEST['pdf']."'" ,',updated' => "'".date('Y-m-d H:i:s')."'" ); error_log(updateSql( "yuai_topic",$this->column,"id='".$_REQUEST['id']."'" ) ); mysql_query( "begin" ); if( $this->putQuery( updateSql( "yuai_topic",$this->column,"id='".$_REQUEST['id']."'" ) ) ): mysql_query( "commit" ); endif; } } ### / record class Topic_Display extends mysqlDBConnect{ ### 潟潟鴻 function Topic_Display(){ $this->mysqlDBConnect(); $op_id = $_REQUEST['id']; $this->column = array( 'display' => "'".$_REQUEST['flag']."'" ); ### 脂 if( $this->putQuery( updateSql( "yuai_topic",$this->column,"id='".$op_id."'" ) ) ): endif; } } ### delete record class Topic_Delete extends mysqlDBConnect{ ### 潟潟鴻 function Topic_Delete(){ $this->mysqlDBConnect(); $del_id = $_REQUEST['id']; $this->column = array( 'delflag' => "'1'" ); ### 脂 if( $this->putQuery( updateSql( "yuai_topic",$this->column,"id='".$del_id."'" ) ) ): endif; } } ?>