Changeset 21514 for branches/version-2_12-dev/data/class/SC_Query.php
- Timestamp:
- 2012/02/15 19:56:17 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/SC_Query.php
r21490 r21514 47 47 * @param boolean $new 新規に接続を行うかどうか 48 48 */ 49 function SC_Query($dsn = "", $force_run = false, $new = false) {50 51 if ($dsn == "") {49 function SC_Query($dsn = '', $force_run = false, $new = false) { 50 51 if ($dsn == '') { 52 52 $dsn = DEFAULT_DSN; 53 53 } … … 90 90 * @return SC_Query シングルトンの SC_Query インスタンス 91 91 */ 92 function getSingletonInstance($dsn = "", $force_run = false, $new = false) {92 function getSingletonInstance($dsn = '', $force_run = false, $new = false) { 93 93 if (!isset($GLOBALS['_SC_Query_instance']) 94 94 || is_null($GLOBALS['_SC_Query_instance'])) { … … 153 153 * @return array|null 154 154 */ 155 function select($col, $table, $where = "", $arrWhereVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) {155 function select($col, $table, $where = '', $arrWhereVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) { 156 156 $sqlse = $this->getSql($col, $table, $where, $arrWhereVal); 157 157 return $this->getAll($sqlse, $arrWhereVal, $fetchmode); … … 303 303 $sqlse .= " WHERE $where"; 304 304 } elseif (strlen($this->where) >= 1) { 305 $sqlse .= " WHERE ". $this->where;305 $sqlse .= ' WHERE ' . $this->where; 306 306 // 実行時と同じくキャストしてから評価する (空文字を要素1の配列と評価させる意図) 307 307 $arrWhereValForEval = (array)$arrWhereVal; … … 342 342 if (is_numeric($limit) && is_numeric($offset)) { 343 343 344 $option = " LIMIT ". $limit;345 $option.= " OFFSET ". $offset;344 $option = ' LIMIT ' . $limit; 345 $option.= ' OFFSET ' . $offset; 346 346 $this->option .= $option; 347 347 } … … 361 361 $this->groupby = ''; 362 362 } else { 363 $this->groupby = "GROUP BY ". $str;363 $this->groupby = 'GROUP BY ' . $str; 364 364 } 365 365 return $this; … … 375 375 */ 376 376 function andWhere($str) { 377 if ($this->where != "") {378 $this->where .= " AND ". $str;377 if ($this->where != '') { 378 $this->where .= ' AND ' . $str; 379 379 } else { 380 380 $this->where = $str; … … 392 392 */ 393 393 function orWhere($str) { 394 if ($this->where != "") {395 $this->where .= " OR ". $str;394 if ($this->where != '') { 395 $this->where .= ' OR ' . $str; 396 396 } else { 397 397 $this->where = $str; … … 427 427 $this->order = ''; 428 428 } else { 429 $this->order = "ORDER BY ". $str;429 $this->order = 'ORDER BY ' . $str; 430 430 } 431 431 return $this; … … 442 442 function setLimit($limit) { 443 443 if (is_numeric($limit)) { 444 $this->option = " LIMIT ".$limit;444 $this->option = ' LIMIT ' .$limit; 445 445 } 446 446 return $this; … … 457 457 function setOffset($offset) { 458 458 if (is_numeric($offset)) { 459 $this->offset = " OFFSET ".$offset;459 $this->offset = ' OFFSET ' .$offset; 460 460 } 461 461 return $this; … … 480 480 foreach ($sqlval as $key => $val) { 481 481 $strcol .= $key . ','; 482 if (strcasecmp( "Now()", $val) === 0) {482 if (strcasecmp('Now()', $val) === 0) { 483 483 $strval .= 'Now(),'; 484 484 } else if (strcasecmp('CURRENT_TIMESTAMP', $val) === 0) { … … 501 501 return false; 502 502 } 503 // 文末の ","を削除503 // 文末の','を削除 504 504 $strcol = preg_replace("/,$/", "", $strcol); 505 505 $strval = preg_replace("/,$/", "", $strval); … … 522 522 * @return 523 523 */ 524 function update($table, $sqlval, $where = "", $arrWhereVal = array(), $arrRawSql = array(), $arrRawSqlVal = array()) {524 function update($table, $sqlval, $where = '', $arrWhereVal = array(), $arrRawSql = array(), $arrRawSqlVal = array()) { 525 525 $arrCol = array(); 526 526 $arrVal = array(); … … 528 528 529 529 foreach ($sqlval as $key => $val) { 530 if (strcasecmp( "Now()", $val) === 0) {530 if (strcasecmp('Now()', $val) === 0) { 531 531 $arrCol[] = $key . '= Now()'; 532 532 } else if (strcasecmp('CURRENT_TIMESTAMP', $val) === 0) { … … 539 539 } 540 540 541 if ($arrRawSql != "") {541 if ($arrRawSql != '') { 542 542 foreach ($arrRawSql as $key => $val) { 543 543 $arrCol[] = "$key = $val"; … … 551 551 } 552 552 553 // 文末の ","を削除553 // 文末の','を削除 554 554 $strcol = implode(', ', $arrCol); 555 555 … … 577 577 * @return integer MAX文の実行結果 578 578 */ 579 function max($col, $table, $where = "", $arrval = array()) {579 function max($col, $table, $where = '', $arrval = array()) { 580 580 $ret = $this->get("MAX($col)", $table, $where, $arrval); 581 581 return $ret; … … 591 591 * @return integer MIN文の実行結果 592 592 */ 593 function min($col, $table, $where = "", $arrval = array()) {593 function min($col, $table, $where = '', $arrval = array()) { 594 594 $ret = $this->get("MIN($col)", $table, $where, $arrval); 595 595 return $ret; … … 605 605 * @return mixed SQL の実行結果 606 606 */ 607 function get($col, $table, $where = "", $arrWhereVal = array()) {607 function get($col, $table, $where = '', $arrWhereVal = array()) { 608 608 $sqlse = $this->getSql($col, $table, $where, $arrWhereVal); 609 609 // SQL文の実行 … … 652 652 * @return array array('カラム名' => '値', ...)の連想配列 653 653 */ 654 function getRow($col, $table, $where = "", $arrWhereVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) {654 function getRow($col, $table, $where = '', $arrWhereVal = array(), $fetchmode = MDB2_FETCHMODE_ASSOC) { 655 655 656 656 $sql = $this->getSql($col, $table, $where, $arrWhereVal); … … 685 685 * @return array SQL の実行結果の配列 686 686 */ 687 function getCol($col, $table, $where = "", $arrWhereVal = array()) {687 function getCol($col, $table, $where = '', $arrWhereVal = array()) { 688 688 $sql = $this->getSql($col, $table, $where, $arrWhereVal); 689 689 $sql = $this->dbFactory->sfChangeMySQL($sql); … … 716 716 * @return 717 717 */ 718 function delete($table, $where = "", $arrval = array()) {718 function delete($table, $where = '', $arrval = array()) { 719 719 if (strlen($where) <= 0) { 720 720 $sqlde = "DELETE FROM $table"; … … 967 967 * @return string トレースしたエラー文字列 968 968 */ 969 function traceError($error, $sql = "", $arrVal = false) {969 function traceError($error, $sql = '', $arrVal = false) { 970 970 $scheme = ''; 971 971 if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') { 972 $scheme = "http://";972 $scheme = 'http://'; 973 973 } else { 974 $scheme = "https://";974 $scheme = 'https://'; 975 975 } 976 976 977 977 $err = $scheme . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . "\n\n" 978 . "SERVER_ADDR: ". $_SERVER['SERVER_ADDR'] . "\n"979 . "REMOTE_ADDR: ". $_SERVER['REMOTE_ADDR'] . "\n"980 . "USER_AGENT: ". $_SERVER['HTTP_USER_AGENT'] . "\n\n"981 . "SQL: ". $sql . "\n\n";978 . 'SERVER_ADDR: ' . $_SERVER['SERVER_ADDR'] . "\n" 979 . 'REMOTE_ADDR: ' . $_SERVER['REMOTE_ADDR'] . "\n" 980 . 'USER_AGENT: ' . $_SERVER['HTTP_USER_AGENT'] . "\n\n" 981 . 'SQL: ' . $sql . "\n\n"; 982 982 if ($arrVal !== false) { 983 $err .= "PlaceHolder: ". var_export($arrVal, true) . "\n\n";983 $err .= 'PlaceHolder: ' . var_export($arrVal, true) . "\n\n"; 984 984 } 985 985 $err .= $error->getMessage() . "\n\n";
Note: See TracChangeset
for help on using the changeset viewer.