国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

? ??? ?? PHP ???? PHP PDO ?????? ?? ??? ??? ??

PHP PDO ?????? ?? ??? ??? ??

Jul 25, 2016 am 08:51 AM

  1. /**

  2. * ?????? PDO ??
  3. */
  4. class MysqlPdo {
  5. public static $PDOStatement = null;
  6. /**
  7. * ?????? ?? ???? ??
  8. * @var array
  9. * @access public
  10. */
  11. public static $config = array();
  12. /**
  13. * ?? ?? ?? ??
  14. * @var bool
  15. * @access public
  16. */
  17. public static $pconnect = false;
  18. /**
  19. * ?? ???
  20. * @var string
  21. * @access public
  22. */
  23. public static $error = '';
  24. /**
  25. * ??? ??, Pdo ???? ??? ????? ??????? ?? ???? ?????.
  26. * @var object
  27. * @access public
  28. */
  29. protected static $link;
  30. /**
  31. * ?????? ?? ??
  32. * @var bool
  33. * @access public
  34. */
  35. public static $connected = false;
  36. /**
  37. * ?????? ??
  38. * @var string
  39. * @access public
  40. */
  41. public static $dbVersion = null;
  42. /**
  43. * ?? SQL ?
  44. * @var string
  45. * @access public
  46. */
  47. public static $queryStr = ' ';
  48. /**
  49. * ????? ??? ???? ID
  50. * @var ??
  51. * @access public
  52. */
  53. public static $lastInsertId = null;
  54. /**
  55. * ??? ?? ??? ?? ?????.
  56. * @var ??
  57. * @access public
  58. */
  59. public static $numRows = 0;
  60. // ???? ??? ?
  61. public static $transTimes = 0;
  62. /**
  63. * ???,
  64. * @param $dbconfig ?????? ?? ?? ??, array('ServerName', 'UserName', 'Password', 'DefaultDb', 'DB_Port', 'DB_TYPE')
  65. */
  66. ?? ?? __construct($dbConfig=''){
  67. if (!class_exists('PDO') ) self::throw_Exception("???? ??: PDO");
  68. //????? ???? ??? ?? ??? ??? ?????
  69. if (!is_array($dbConfig)) {
  70. $dbConfig = ??(
  71. '??? ??' => DB_HOST,
  72. '??? ??' => DB_USER,
  73. '????' => DB_PWD,
  74. '??????' => DB_NAME,
  75. '??? ??' => ; DB_PORT,
  76. 'dbms' => DB_TYPE,
  77. 'dsn' => DB_TYPE.":host=".DB_HOST.";dbname=".DB_NAME
  78. );
  79. }
  80. if(empty($dbConfig['hostname'])) self::throw_Exception("?????? ??? ???? ??");
  81. self::$config = $dbConfig;
  82. if(empty( self:: $config['params'])) self::$config['params'] = array();
  83. /**************************************?? ???************ *******************************/
  84. if (!isset(self::$ link) ) {
  85. $configs = self::$config;
  86. if(self::$pconnect) {
  87. $configs['params'][constant('PDO::ATTR_PERSISTENT')] = true;
  88. }
  89. {
  90. self::$link = new PDO( $configs['dsn'], $configs['username'], $configs['password'],$configs[ 'params' ?? ]);
  91. } catch (PDOException $e) {
  92. self::throw_Exception($e->getMessage());
  93. }
  94. if(!self::$link ) {
  95. self::throw_Exception('PDO ?? ??');
  96. false ??;
  97. }
  98. self::$link->exec('SET NAMES '.DB_CHARSET);
  99. self: :$dbVersion = self::$link->getAttribute(constant("PDO::ATTR_SERVER_INFO"));
  100. // ??? ????? ??
  101. self::$connected = true;
  102. // ?????? ?? ?? ?? ?? ??
  103. unset($configs);
  104. }
  105. return self::$link;
  106. }
  107. /**
  108. * ?? ?? ??
  109. * @access ??
  110. */
  111. ?? ?? ?? () {
  112. self::$PDOStatement = null;
  113. }
  114. /************************/
  115. /* ?????? ??*/
  116. /************************/
  117. /**
  118. * ?? ?? ??? ????
  119. * @access ??
  120. * @return ??
  121. */
  122. ?? ?? getAll($sql=null) {
  123. if($sql != null)
  124. {
  125. self::query($sql) ;
  126. }
  127. //??? ?? ??
  128. $result = self::$PDOStatement->fetchAll(constant('PDO::FETCH_ASSOC'));
  129. return $result;
  130. }
  131. /**
  132. * ?? ?? ????
  133. * @access ??
  134. * @param string $sql SQL ??
  135. * @param ?? $seek ??? ??
  136. * @return ??
  137. */
  138. ?? ?? getRow($sql=null) {
  139. if($sql != null)
  140. {
  141. self::query($sql ) ;
  142. }
  143. // ?? ?? ??
  144. $result = self::$PDOStatement->fetch(constant('PDO::FETCH_ASSOC'),constant('PDO::FETCH_ORI_NEXT')) ;
  145. return $result;
  146. }
  147. /**
  148. * SQL ?? ???? ?? ?? ?? ??? ???? ??
  149. * @access ??
  150. * @param string $sql SQL ??
  151. * @return ??
  152. */
  153. ?? ?? doSql($sql='') {
  154. if(self::isMainIps($sql) ) {
  155. return self::execute($sql);
  156. }else {
  157. return self::getAll($sql);
  158. }
  159. }
  160. /**
  161. * ??? ID? ???? ???? ??? ??(?? ??? ???? ??)
  162. * @access ??
  163. * @param ?? $priId ?? ? ID
  164. * @param string $tables ??? ??? ??
  165. * @param string $fields ?? ??
  166. * @return ArrayObject ??? ???
  167. */
  168. ?? ?? findById($tabName,$priId,$fields='*'){
  169. $sql = 'SELECT %s FROM %s WHERE id=%d';
  170. self ??: : getRow(sprintf($sql, self::parseFields($fields), $tabName, $priId));
  171. }
  172. /**
  173. * 尋找記錄
  174. * @access function
  175. * @param string $tables 資料表名
  176. * @param mixed $where 查詢條件
  177. * @param string $fields 欄位名稱
  178. * @param string $order 排序
  179. * @param string $limit 取多少條資料
  180. * @param string $group 分組
  181. * @param string $having
  182. * @param boolean $lock 是否加鎖
  183. * @return ArrayObject
  184. */
  185. 靜態(tài)函數(shù) find($tables,$where="",$fields='*',$order=null,$limit=null,$group=null,$ having=null) {
  186. $sql = 'SELECT '.self::parseFields($fields)
  187. .' FROM '.$tables
  188. .self::parseWhere($where)
  189. .self::parseGroup($group)
  190. .self::parseHaving($having)
  191. .self::parseOrder( $order)
  192. .self::parseLimit($limit);
  193. $dataAll = self::getAll($sql);
  194. if(count($dataAll)==1){$rlt=$ dataAll[0];}else{$rlt=$dataAll;}
  195. return $rlt;
  196. }
  197. /**
  198. * 插入(單一)記錄
  199. * @access function
  200. * @param mixed $data 資料
  201. * @param string $table 資料表名
  202. * @return false | integer
  203. */
  204. function add($data,$table) {
  205. //過濾提交資料
  206. $data=self::filterPost($table,$data);
  207. foreach ($data as $key=>$val){
  208. if(is_array( $ val) && strtolower($val[0]) == 'exp') {
  209. $val = $val[1]; // 使用表達(dá)式 ???
  210. }elseif (is_scalar($val)){
  211. $val = self::fieldFormat($val);
  212. }else{
  213. //刪除複合物件
  214. 繼續(xù);
  215. }
  216. $data[$key] = $val;
  217. }
  218. $fields = array_keys($data);
  219. array_walk($fields, array($this, 'addSpecialChar'));
  220. $fieldsStr = implode(',', $fields);
  221. $values = array_values($data);
  222. $valuesStr = implode(',', $values);
  223. $sql = '插入'.$table.' ('.$fieldsStr.') VALUES ('.$valuesStr.')';
  224. return self::execute($sql);
  225. }
  226. /**
  227. * 更新記錄
  228. * @access function
  229. * @param mixed $sets 資料
  230. * @param string $table 資料表名
  231. * @param string $where 更新條件
  232. * @param string $limit
  233. * @param string $order
  234. * @return false | integer
  235. */
  236. 靜態(tài)函數(shù)update($sets,$table,$where,$limit=0,$order='') {
  237. $sets = self::filterPost($table,$sets);
  238. $sql = '更新「.$表」。 self::execute($sql );
  239. }
  240. /**
  241. * 儲存某個欄位的值
  242. * @access function
  243. * @param string $field 要儲存的欄位名稱
  244. * @param string $value 欄位值
  245. * @param string $ table 資料表
  246. * @param string $where 儲存條件
  247. * @param boolean $asString 欄位值是否為字串
  248. * @return void
  249. */
  250. 靜態(tài)函式setField($field, $value, $table, $condition="", $asString=false ) {
  251. //如果有'(' 視為SQL 指令更新否則更新欄位內(nèi)容為純字串
  252. if(false === strpos($value,'(') || $asString) $value = '"'.$value .'"';
  253. $sql = '更新'.$table.' SET '.$field.'='.$value.self::parseWhere($condition);
  254. 回傳self::execute( $sql);
  255. }
  256. /**
  257. * 刪除記錄
  258. * @access function
  259. * @param mixed $where 為條件Map、Array或String
  260. * @param string $table 資料表名
  261. * @param string $limit
  262. * @param string $order
  263. * @return false | integer
  264. */靜態(tài)函式($where,$table,$limit='',$order='' ) {
  265. $sql = 'DELETE FROM '.$table.self::parseWhere($where).self::parseOrder($order).self::parseLimit($limit);
  266. 回傳self::執(zhí)行($sql);
  267. }
  268. /**
  269. ----------------------------------------------- -----------
  270. * 修改或儲存資料(僅用於單表操作)
  271. * 有主鍵ID則為修改,無主鍵ID則為增加
  272. * 修改記錄:
  273. ---------------------------------------------- ------------
  274. * @access function
  275. ---------------------------- ------------------------------
  276. * @param $tabName 表名
  277. * @param $aPost 提交表單的$_POST
  278. * @param $priId 主鍵ID
  279. * @param $aNot 要排除的一個字段或數(shù)組
  280. * @param $aCustom 自訂的數(shù)組,附加到資料庫中保存
  281. * @param $isExits 是否已經(jīng)存在存在:true, 不存在:false
  282. ------------------------------- ---------------------------
  283. * @return Boolean 修改或儲存是否成功
  284. -------- --------------------------------------------------
  285. */
  286. 函數(shù)saveOrUpdate($tabName, $aPost, $priId="", $aNot="", $aCustom="" , $isExits=false) {
  287. if(empty($tabName) || !is_array($aPost) || is_int($aNot)) return false;
  288. if(is_string($aNot) && !empty($aNot)) $aNot = array($aNot);
  289. if(is_array($aNot) && is_int(key ) ($aNot))) $aPost = array_diff_key($aPost, array_flip($aNot));
  290. if(is_array($aCustom) ) && is_string(key($aCustom))) $aPost = array_merge($aCustom))) $aPost = array_merge($aCustom))) $aPost = aPostge($aPost , $aCustom);
  291. if (empty($priId) && !$isExits) { // 新增
  292. $aPost = array_filter ($aPost, array($this, 'removeEmpty'));
  293. return self::add($aPost, $tabName);
  294. }else { //修改
  295. return self::update($aPost, $tabName, "id=".$priId);
  296. }
  297. }
  298. /**
  299. * ?? ??? sql ? ????
  300. * @access ??
  301. * @param
  302. * @return String ??? SQL
  303. */
  304. ?? ?? getLastSql() {
  305. $link = self::$link;
  306. if ( !$link ) return false;
  307. return self::$queryStr;
  308. }
  309. /* *
  310. * ????? ??? ID ????
  311. * @access ??
  312. * @param
  313. * @return ?? ????? ??? ??? ID
  314. */
  315. ?? ?? getLastInsId(){
  316. $link = self::$link;
  317. if ( !$link ) return false;
  318. return self::$lastInsertId;
  319. }
  320. /**
  321. * DB ?? ????
  322. * @access ??
  323. * @param
  324. * @return ???
  325. */
  326. ?? ?? getDbVersion(){
  327. $link = self::$link;
  328. if ( !$link ) return false;
  329. return self::$dbVersion;
  330. }
  331. /**
  332. * ?????? ??? ?? ????
  333. * @access ??
  334. * @return ??
  335. */
  336. ?? ?? getTables() {
  337. $info = array();
  338. if(self::query ("??? ??")) {
  339. $result = self::getAll();
  340. foreach ($result as $key => $val) {
  341. $info[$key] = current( $val);
  342. }
  343. }
  344. return $info;
  345. }
  346. /**
  347. * ??? ???? ?? ?? ????
  348. * @access ??
  349. * @return ??
  350. */
  351. ?? ?? getFields($tableName) {
  352. //獲取數(shù)據(jù)庫聯(lián)接
  353. $link = self::$link;
  354. $sql = "SELECT
  355. ORDINAL_POSITION ,COLUMN_NAME, COLUMN_TYPE, DATA_TYPE,
  356. IF(ISNULL(CHARACTER_MAXIMUM_LENGTH), (NUMERIC_PRECISION NUMERIC_SCALE ), CHARACTER_MAXIMUM_LENGTH ) AS MAXCHAR,
  357. IS_NULLABLE, COLUMN_DEFAULT, COLUMN_KEY, EXTRA, COLUMN_COMMENT
  358. FROM
  359. INFORMATION_SCHEMA.COLUMNS
  360. WHERE
  361. TABLE_NAME = :tabName AND TABLE_SCHEMA='".DB_NAME."'";
  362. self::$queryStr = sprintf($sql, $tableName);
  363. $sth = $link->prepare($sql);
  364. $sth->bindParam(':tabName', $ tableName);
  365. $sth->execute();
  366. $result = $sth->fetchAll(constant('PDO::FETCH_ASSOC'));
  367. $info = array();
  368. foreach($result as $key => $val) {
  369. $info[$val['COLUMN_NAME']] = array(
  370. '??' => $val['ORDINAL_POSITION'],
  371. '??' => $val[ 'COLUMN_NAME'],
  372. '??' => $val['COLUMN_TYPE'],
  373. 'd_type' => $val['DATA_TYPE'],
  374. '??' => ['MAXCHAR'],
  375. 'notnull' => (strtolower($val['IS_NULLABLE']) == "???"),
  376. 'default' => $val['COLUMN_DEFAULT'],
  377. '??' => (strtolower($val['COLUMN_KEY']) == '??'),
  378. 'autoInc' => (strtolower($val['EXTRA']) == ' auto_increment'),
  379. 'comment' => $val['COLUMN_COMMENT']
  380. );
  381. }
  382. // 有錯誤則拋take異常
  383. self::haveErrorThrowException();
  384. $info ??;
  385. }
  386. /**
  387. * ?????? ??
  388. * @access ??
  389. */
  390. ?? ?? close() {
  391. self::$link = null;
  392. }
  393. / **
  394. * SQL ?? ?? ???
  395. * @access ??
  396. * @param string $str SQL ??
  397. * @return string
  398. */
  399. ?? ?? escape_string($str) {
  400. return addedlashes($str);
  401. }
  402. /************************/
  403. /* 內(nèi)part操? ?? */
  404. /************************/
  405. /**
  406. * ??? ???? ??? ?????
  407. * @access ??
  408. * @return
  409. */
  410. static function haveErrorThrowException() {
  411. $obj =empty(self::$PDOStatement) ? self::$link : self::$PDOStatement;
  412. $arrError = $obj->errorInfo();
  413. if($arrError[0] !== '00000') { // 有錯誤信息
  414. self::$error = $arrError[0]."|".$arrError[2]. "
    [ SQL ] : ".self::$queryStr."
    ";
  415. self::throw_Exception(self::$error);
  416. false? ??;
  417. }
  418. //主要針對execute()???拋出異常
  419. if(self::$queryStr=='')self::throw_Exception('??? ?? ?????

    [ SQL語句 ] :');
  420. }
  421. /**
  422. * where ??
  423. * @access ??
  424. * @param $where ?? ?? ??
  425. * @return ???
  426. */
  427. ?? ?? ?? ??($where) {
  428. $whereStr = '';
  429. if( is_string($where) || is_null($where)) {
  430. $whereStr = $where;
  431. }
  432. ? ? ??($whereStr)?'':' WHERE '.$whereStr;
  433. }
  434. /**
  435. * order ??
  436. * @access function
  437. * @param mixed $order ??
  438. * @return string
  439. */
  440. ?? ?? parseOrder($order) {
  441. $orderStr = '';
  442. if(is_array($order))
  443. $orderStr .= ' ORDER BY '.implode(',', $order);
  444. else if(is_string($order) && !empty($order))
  445. $orderStr .= ' ORDER BY '.$order;
  446. return $orderStr;
  447. }
  448. /**
  449. * ????
  450. * @access ??
  451. * @param string $limit
  452. * @return string
  453. */
  454. ?? ?? parseLimit($limit) {
  455. $limitStr = '';
  456. if(is_array($limit) )) {
  457. if(count($limit)>1)
  458. $limitStr .= ' LIMIT '.$limit[0].' , '.$limit[1].' ';
  459. else
  460. $limitStr .= ' LIMIT '.$limit[0].' ';
  461. } else if(is_string($limit) && !empty($limit)) {
  462. $limitStr .= ' LIMIT '.$limit.' ';
  463. }
  464. $limitStr ??
  465. }
  466. /**
  467. * ?? ??
  468. * @access ??
  469. * @param ?? $group
  470. * @return ???
  471. */
  472. ?? ?? parseGroup($group) {
  473. $groupStr = '';
  474. if(is_array($group))
  475. $groupStr .= ' GROUP BY '.implode(',', $group);
  476. else if(is_string($group) && !empty($group))
  477. $groupStr .= ' GROUP BY '.$group;
  478. empty($groupStr)?'':$groupStr;
  479. }
  480. /**
  481. * have分析
  482. * @access ??
  483. * @param string $having
  484. * @return string
  485. */
  486. ?? ??parseHaving($having) {
  487. $havingStr = '';
  488. if(is_string($having) && !empty($having))
  489. $havingStr .= ' HAVING '.$having;
  490. return $havingStr;
  491. }
  492. /**
  493. * ?? ??
  494. * @access ??
  495. * @param ?? $??
  496. * @return ???
  497. */
  498. function parseFields($fields) {
  499. if(is_array($fields)) {
  500. array_walk($fields, array($this, 'addSpecialChar'));
  501. $fieldsStr = implode(',', $fields);
  502. }else if(is_string($fields) && !empty($fields)) {
  503. if( false === strpos($fields,'`') ) {
  504. $fields =explode(',',$fields);
  505. array_walk($fields, array($this, 'addSpecialChar'));
  506. $fieldsStr = implode(',', $fields );
  507. }else {
  508. $fieldsStr = $fields;
  509. }
  510. }else $fieldsStr = '*';
  511. return $fieldsStr;
  512. }
  513. /**
  514. * ??? ???? ? ???? ?? ??
  515. * @access ??
  516. * @param ?? $? ??
  517. * @return ???
  518. */
  519. ??? ?? parseSets($sets) {
  520. $setsStr = '';
  521. if(is_array($sets)){
  522. foreach ($sets as $key=> $val){
  523. $key = self::addSpecialChar($key);
  524. $val = self::fieldFormat($val);
  525. $setsStr .= "$key = ".$val. ",";
  526. }
  527. $setsStr = substr($setsStr,0,-1);
  528. }else if(is_string($sets)) {
  529. $setsStr = $sets;
  530. }
  531. return $setsStr;
  532. }
  533. /**
  534. * ?? ?? ??
  535. * @access ??
  536. * @param ?? $value
  537. * @return ??
  538. */
  539. ?? ?? fieldFormat(&$value) {
  540. if(is_int($value)) {
  541. $value = intval($value);
  542. } else if(is_float($value)) {
  543. $value = floatval($value);
  544. } elseif(preg_match('/^(w* ( |-|*|/)?w*)$/i',$value)){
  545. // 支持在字段的值里face直接使用其它字段
  546. // 例如 (?? 1) (??)必須包含括號
  547. $value = $value;
  548. }else if(is_string($value)) {
  549. $value = '''.self::escape_string($value).''';
  550. }
  551. return $value;
  552. }
  553. /**
  554. *
  555. ? ?? ?? ? ??? ??? ` ??* ??? ??? ???? mysql? ?? ???? ??
  556. * @access ??
  557. * @param ?? $?
  558. * @return ??
  559. */
  560. ?? ?? addSpecialChar(&$value) {
  561. if( '*' == $value | | false !== strpos($value,'(') || false !== strpos($value,'.') || false !== strpos($value,'`')) {
  562. //如果包含* 或者 使用了sql方法 則不?處理
  563. } elseif(false === strpos($value,'`') ) {
  564. $value = '`'.trim($value).'` ';
  565. }
  566. return $value;
  567. }
  568. /**
  569. ---------------------------------- ----------
  570. * ? ?? ??
  571. ------------- ---- ------------
  572. * @access ??
  573. ---------- ----- ----------------
  574. * @param ?? $ ?
  575. ---------------------------- ----- -------------
  576. * @return ??
  577. ---------- ---- -----------------
  578. */
  579. ?? ?? RemoveEmpty($value){
  580. return !empty($value);
  581. }
  582. /**
  583. * ?? SELECT, SHOW ? ?? ??? ?? ?? ??
  584. * @access ??
  585. * @param string $sql sql ??
  586. * @return ??
  587. */
  588. ?? ?? ??($sql='') {
  589. // 獲取數(shù)據(jù)庫聯(lián)接
  590. $link = self::$link;
  591. if ( !$link ) return false;
  592. self::$queryStr = $sql;
  593. //釋放前次的查詢結(jié)果
  594. if ( !empty(self::$PDOStatement) ) self ::free();
  595. self::$PDOStatement = $link->prepare(self::$queryStr);
  596. $bol = self::$PDOStatement->execute();
  597. // 有錯誤則拋 Out異常
  598. self::haveErrorThrowException();
  599. return $bol;
  600. }
  601. /**
  602. * ?????? ?? ??
  603. * @access ??
  604. * @param string $sql ???
  605. * @param boolean $lock ?? ??(???? ?? ?? ??)
  606. * @return void
  607. ?? ?? ??($sql='',$lock=false) {
  608. if(empty($sql)) $sql = $this->queryStr
  609. return $this->_execute; ($SQL)
  610. }*/
  611. /**
  612. * INSERT, UPDATE, DELETE ???
  613. * @access ??
  614. * @param string $sql sql ??
  615. * @return ??
  616. * /
  617. ?? ?? ??($sql='') {
  618. // 獲取數(shù)據(jù)庫聯(lián)接
  619. $link = self::$link;
  620. if ( !$link ) return false;
  621. self::$queryStr = $sql;
  622. //釋放前次的查詢結(jié)果
  623. if ( !empty(self::$PDOStatement) ) self::free();
  624. $result = $link ->exec(self::$queryStr);
  625. // ?? false;
  626. } else {
  627. self::$numRows = $result;
  628. self::$lastInsertId = $link->lastInsertId();
  629. return self::$numRows;
  630. }
  631. }
  632. /**
  633. * ?????? ?? ???? ??
  634. * @access private
  635. * @param string $query SQL ??
  636. * @return boolen ?? ??? ?? false ??
  637. */
  638. ?? ?? isMainIps($query) {
  639. $queryIps = 'INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|LOAD DATA|SELECT .* INTO|COPY |ALTER|GRANT|REVOKE|LOCK|UNLOCK';
  640. if (preg_match('/^s*"?(' . $queryIps . ')s /i', $query)) {
  641. true? ?????.
  642. }
  643. false ??;
  644. }
  645. /**
  646. * POST ?? ??? ???
  647. * @access private
  648. * @param ?? $data POST ?? ???
  649. * @param string $table ??? ??? ??
  650. * @return ?? $newdata
  651. */
  652. ?? ?? filterPost($table,$data) {
  653. $table_column = self::getFields( $table);
  654. $newdata=array();
  655. foreach($table_column as $key=>$val){
  656. if(array_key_exists($key,$data) && ($data[$ ?])!==''){
  657. $newdata[$key] = $data[$key];
  658. }
  659. }
  660. return $newdata;
  661. }
  662. / **
  663. * ?? ??
  664. * @access ??
  665. * @return void
  666. */
  667. ?? ?? startTrans() {
  668. //數(shù)據(jù)rollback 支持
  669. $link = self::$link;
  670. if ( !$link ) return false;
  671. if (self::$transTimes == 0) {
  672. $link->beginTransaction();
  673. }
  674. self::$transTimes ;
  675. return ;
  676. }
  677. /**
  678. * ??? ?? ???? ?? ??? ?????.
  679. * @access ??
  680. * @return boolen
  681. */
  682. ?? ?? ??() {
  683. $link = self::$link;
  684. if ( !$link ) return false;
  685. if (self::$ transTimes > 0) {
  686. $result = $link->commit();
  687. self::$transTimes = 0;
  688. if(!$result){
  689. self::throw_Exception( self::$error());
  690. false ??;
  691. }
  692. }
  693. true ??;
  694. }
  695. /**
  696. * ???? ??
  697. * @access ??
  698. * @return bolen
  699. */
  700. ?? ?? ?? () {
  701. $link = self::$link;
  702. if ( !$link ) return false;
  703. if (self::$transTimes > 0) {
  704. $result = $link->rollback();
  705. self::$transTimes = 0;
  706. if(!$result){
  707. self::throw_Exception(self:: $error());
  708. false ??;
  709. }
  710. }
  711. true ??;
  712. }

  713. /**

  714. * ?? ??
  715. * @access ??
  716. * @return void
  717. */
  718. ?? ?? throw_Exception($err){
  719. echo '
    ??:'.$err.'
    ';
  720. }
  721. }

復(fù)代碼


? ????? ??
? ?? ??? ????? ???? ??? ??????, ???? ?????? ????. ? ???? ?? ???? ?? ??? ?? ????. ???? ??? ???? ???? ??? ?? admin@php.cn?? ?????.

? AI ??

Undresser.AI Undress

Undresser.AI Undress

???? ?? ??? ??? ?? AI ?? ?

AI Clothes Remover

AI Clothes Remover

???? ?? ???? ??? AI ?????.

Video Face Swap

Video Face Swap

??? ??? AI ?? ?? ??? ???? ?? ???? ??? ?? ????!

???

??? ??

???++7.3.1

???++7.3.1

???? ?? ?? ?? ???

SublimeText3 ??? ??

SublimeText3 ??? ??

??? ??, ???? ?? ????.

???? 13.0.1 ???

???? 13.0.1 ???

??? PHP ?? ?? ??

???? CS6

???? CS6

??? ? ?? ??

SublimeText3 Mac ??

SublimeText3 Mac ??

? ??? ?? ?? ?????(SublimeText3)

???

??? ??

?? ????
1747
16
Cakephp ????
1600
56
??? ????
1542
28
PHP ????
1400
31
???
PHP ?? API ????? ?? ??? ?????? PHP ?? API ????? ?? ??? ?????? Jun 14, 2025 am 12:27 AM

ToversionAphp ??, forclarityandeasofrouting, ac

PHP?? ?? ? ??? ????? ????????? PHP?? ?? ? ??? ????? ????????? Jun 20, 2025 am 01:03 AM

TOSECURELYHANDLEAUSTENCENDACTIONANDACTERIZINGINPHP, FORCUCTSESTEPS : 1. ALWAYSHASHPASSWORTHPASSWORD_HASH () ? VERVERIFYUSINGPANSWORD_VERIFY (), usePREPAREDSTATEMENTSTOPREVENTSQLINGERGED, andSTOREUSERSESSEATAIN $ _SESSIONSAFTERLOGIN.2.impleplempletrole ?? ACCESSC

PHP? ?? ?? (??)? ???? ?? ?? ? ? ????? PHP? ?? ?? (??)? ???? ?? ?? ? ? ????? Jun 14, 2025 am 12:25 AM

phpdoesnothaveAbuilt-inweakMapButofferSweakReference.1.WeakReenceAllowsholdingReferences withoutpreventinggarbageCollection.2.ItusteForCaching, Eventlisteners, andMetAdataWithoutAftingObjectLifeCycles.3.youcoucococococococcinccing

PHP? ?? ? ?? ?? ????? ????? ???? ?????? PHP? ?? ? ?? ?? ????? ????? ???? ?????? Jun 14, 2025 am 12:25 AM

ProceduralAndObject-OrientedProgramming (OOP) InphpDiffersiMINTIFINTIONTERINGLISTURE, ??? ? ? DATAHANDLING

PHP?? ?? ???? ??? ??? ?? ? ? ??????? PHP?? ?? ???? ??? ??? ?? ? ? ??????? Jun 19, 2025 am 01:05 AM

PHP?? ?? ???? ???? ????? ??? ?? ??? ???? ?? ??? ??? ??? ???? ????. 1. finfo_file ()? ???? ?? ?? ??? ???? ???/jpeg? ?? ?? ?? ? ?????. 2. uniqid ()? ???? ??? ?? ??? ???? ? Web ?? ????? ??????. 3. php.ini ? html ??? ?? ?? ??? ???? ???? ??? 0755? ?????. 4. Clamav? ???? ???? ???? ??? ??????. ??? ??? ?? ???? ????? ???? ?? ??? ????? ???? ??? ? ??? ?????.

PHP?? == (??? ??)? === (??? ??)? ???? ?????? PHP?? == (??? ??)? === (??? ??)? ???? ?????? Jun 19, 2025 am 01:07 AM

PHP?? ==? ==? ?? ???? ?? ??? ??????. == ?? ??? ?? ?? ?????. ?? ??, 5 == "5"? true? ????, ?? ??? ???? ?? ?? ??? ????? ????? (? : 5 === "5"? false? ?????. ?? ?????? ===? ? ???? ?? ?????? == ?? ??? ??? ???? ?????.

PHP? NOSQL ?????? (? : MongoDB, Redis)? ??? ?? ??? ? ????? PHP? NOSQL ?????? (? : MongoDB, Redis)? ??? ?? ??? ? ????? Jun 19, 2025 am 01:07 AM

?, PHP? ?? ?? ?? ?????? ?? MongoDB ? Redis? ?? NOSQL ??????? ?? ??? ? ????. ?? MongoDBPHP ???? (PECL ?? Composer? ?? ??)? ???? ????? ????? ??? ?????? ? ???? ????? ??, ??, ?? ? ?? ??? ?????. ??, Predis ????? ?? Phpredis ??? ???? Redis? ???? ?? ? ?? ? ??? ???? ??? ????? Phpredis? ???? ?? Predis? ?? ??? ?????. ? ? ?? ??? ???? ? ????? ????.

php (, -, *, /, %)?? ?? ??? ??? ?????? php (, -, *, /, %)?? ?? ??? ??? ?????? Jun 19, 2025 pm 05:13 PM

PHP?? ?? ??? ??? ???? ??? ??? ????. 1. ?? ??? ?? ? ?? ??? ??? ???? ???? ??? ? ????. ??? ??? ???? ????? ????? ???? ????. 2. ?? ?? ?? - ??, ??? ???? ?? ??? ?????. 3. ?? ???? ??? ??? ???? ??? ??? ?????. 4. Division? / ??? ???? 0?? ??? ?? ????? ??? ?? ??? ?? ? ? ????. 5. ???? ??? ???? ?? ?? ? ?? ??? ???? ? ??? ? ???, ??? ?? ? ? ??? ??? ???? ?????. ? ???? ???? ???? ??? ??? ??? ???? ?? ??? ? ??????? ????.

See all articles