Changeset 19690
- Timestamp:
- 2010/11/30 02:50:21 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_5-dev/data/class/SC_Query.php
r19675 r19690 55 55 } 56 56 57 // Debugモード指定 58 $options['debug'] = PEAR_DB_DEBUG; 57 // Debugモード指定 58 // 常時ONにするとメモリが解放されない。 59 // 連続クエリ実行時に問題が生じる。 60 if(DEBUG_MODE) { 61 $options['debug'] = PEAR_DB_DEBUG; 62 } else { 63 $options['debug'] = 0; 64 } 65 59 66 // 持続的接続オプション 60 67 $options['persistent'] = PEAR_DB_PERSISTENT; 68 69 // バッファリング trueにするとメモリが解放されない。 70 // 連続クエリ実行時に問題が生じる。 71 $options['result_buffering'] = false; 61 72 62 73 if ($new) { … … 411 422 412 423 if(count($sqlval) <= 0 ) return false; 413 414 424 foreach ($sqlval as $key => $val) { 415 425 $strcol .= $key . ','; 416 if( eregi("^Now\(\)$", $val)) {426 if(strcasecmp("Now()", $val) === 0) { 417 427 $strval .= 'Now(),'; 428 } else if(strpos($val, '~') === 0) { 429 $strval .= preg_replace("/^~/", "", $val); 418 430 } else { 419 431 $strval .= '?,'; … … 426 438 } 427 439 // 文末の","を削除 428 $strcol = ereg_replace(",$","",$strcol); 429 // 文末の","を削除 430 $strval = ereg_replace(",$","",$strval); 440 $strcol = preg_replace("/,$/", "", $strcol); 441 $strval = preg_replace("/,$/", "", $strval); 431 442 $sqlin = "INSERT INTO $table(" . $strcol. ") VALUES (" . $strval . ")"; 432 443 // INSERT文の実行 433 $ret = $this->query($sqlin, $arrval );444 $ret = $this->query($sqlin, $arrval, false, null, MDB2_PREPARE_MANIP); 434 445 435 446 return $ret; … … 451 462 $arrVal = array(); 452 463 $find = false; 464 453 465 foreach ($sqlval as $key => $val) { 454 if ( eregi("^Now\(\)$", $val)) {466 if (strcasecmp("Now()", $val) === 0) { 455 467 $arrCol[] = $key . '= Now()'; 468 } else if(strpos('~', $val) === 0) { 469 $arrCol[] = $key . '= ' . $val; 456 470 } else { 457 471 $arrCol[] = $key . '= ?'; … … 487 501 488 502 // UPDATE文の実行 489 return $this->query($sqlup, $arrVal );503 return $this->query($sqlup, $arrVal, false, null, MDB2_PREPARE_MANIP); 490 504 } 491 505 … … 626 640 $sqlde = "DELETE FROM $table WHERE $where"; 627 641 } 628 $ret = $this->query($sqlde, $arrval );642 $ret = $this->query($sqlde, $arrval, false, null, MDB2_PREPARE_MANIP); 629 643 return $ret; 630 644 } … … 667 681 * SQL を実行する. 668 682 * 669 * XXX 更新系には exec() を使用するべき683 * FIXME $ignore_errが無視されるようになっているが互換性として問題が無いか確認が必要 670 684 * 671 685 * @param string $n 実行する SQL 文 672 * @param array $arrval ブレースホルダに挿入する値 686 * @param array $arr ブレースホルダに挿入する値 687 * @param boolean $ignore_err MDB2切替で無効化されている (エラーが発生しても処理を続行する場合 true) 688 * @param mixed $types プレースホルダの型指定 デフォルトnull = string 689 * @param mixed $result_types 返値の型指定またはDML実行(MDB2_PREPARE_MANIP) 673 690 * @return array SQL の実行結果の配列 674 691 */ 675 function query($n ,$arr = array(), $ignore_err = false ){692 function query($n ,$arr = array(), $ignore_err = false, $types = null, $result_types = MDB2_PREPARE_RESULT ){ 676 693 677 694 $n = $this->dbFactory->sfChangeMySQL($n); 678 695 679 $sth =& $this->prepare($n );696 $sth =& $this->prepare($n, $types, $result_types); 680 697 if (PEAR::isError($sth) && $this->force_run) { 681 698 return; … … 686 703 return; 687 704 } 688 705 706 //PREPAREの解放 707 $sth->free(); 708 689 709 return $result; 690 710 } … … 775 795 * @access private 776 796 * @param string $sql プリペアドステートメントを構築する SQL 797 * @param mixed $types プレースホルダの型指定 デフォルト null 798 * @param mixed $result_types 返値の型指定またはDML実行(MDB2_PREPARE_MANIP)、nullは指定無し 777 799 * @return MDB2_Statement_Common プリペアドステートメントインスタンス 778 800 */ 779 function prepare($sql ) {780 $sth =& $this->conn->prepare($sql );801 function prepare($sql, $types = null, $result_types = MDB2_PREPARE_RESULT) { 802 $sth =& $this->conn->prepare($sql, $types, $result_types); 781 803 if (PEAR::isError($sth)) { 782 804 if (!$this->force_run) {
Note: See TracChangeset
for help on using the changeset viewer.