English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
예제如下:
<?php class DBDA { public $host="localhost"; public $uid = "root"; public $pwd = "123"; public $dbname = "mydb"; //멤버 메서드 public function Query($sql,$type=1); { $db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname); $r = $db->query($sql); if($type==1); { return $r->fetch_all(); } else { return $r; } } //문자열 반환 방법 public function StrQuery($sql,$type=1); { $db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname); $r = $db->query($sql); if($type==1); { $attr = $r->fetch_all(); $str = ""; foreach($attr as $v) { $str .= implode("^",$v)."|"; } return substr($str,0,strlen($str)-1); } else { return $r; } } //JSON 반환 function JSONQuery($sql,$type=1); { $db = new MySQLi($this->host,$this->uid,$this->pwd,$this->dbname); $r = $db->query($sql); if($type==1); { return json_encode($r->fetch_all(MYSQLI_ASSOC)); } else { return $r; } } }
이상의 PHP 래퍼밸 리턴 Ajax 문자열과 JSON 배열의 방법은 저가给大家 공유한 모든 내용입니다. 모두들에게 참고가 되길 바라며, 많이 응원해 주셔서 감사합니다. 노래教程.