Changeset 21914 for branches/version-2_12-dev/data
- Timestamp:
- 2012/06/12 15:07:25 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/version-2_12-dev/data/class/SC_Query.php
r21904 r21914 39 39 var $order = ''; 40 40 var $force_run = false; 41 static $arrInstance = array(); 41 /** シングルトン動作のためのインスタンスプール配列。キーは DSN の識別情報。 */ 42 static $arrPoolInstance = array(); 42 43 43 44 /** … … 98 99 * @return SC_Query シングルトンの SC_Query インスタンス 99 100 */ 100 function getSingletonInstance($dsn = '', $force_run = false, $new = false) {101 $ key_str = serialize($dsn);102 if ( !isset(SC_Query_Ex::$arrInstance[$key_str])) {103 SC_Query_Ex::$arrInstance[$key_str] =& new SC_Query_Ex($dsn, $force_run, $new);101 static function getSingletonInstance($dsn = '', $force_run = false, $new = false) { 102 $objThis = SC_Query_Ex::getPoolInstance($dsn); 103 if (is_null($objThis)) { 104 $objThis = SC_Query_Ex::setPoolInstance(new SC_Query_Ex($dsn, $force_run, $new), $dsn); 104 105 } 105 106 /* … … 109 110 * 厳密な意味でのシングルトンではないが、パフォーマンス的に大差は無い。 110 111 */ 111 return clone SC_Query_Ex::$arrInstance[$key_str];112 return clone $objThis; 112 113 } 113 114 … … 1106 1107 GC_Utils_Ex::gfPrintLog($msg, DB_LOG_REALFILE); 1107 1108 } 1109 1110 /** 1111 * インスタンスをプールする 1112 * 1113 * @param SC_Query $objThis プールするインスタンス 1114 * @param string $dsn データソース名 1115 * @return SC_Query プールしたインスタンス 1116 */ 1117 static function setPoolInstance(&$objThis, $dsn = '') { 1118 $key_str = serialize($dsn); 1119 return SC_Query_Ex::$arrPoolInstance[$key_str] = $objThis; 1120 } 1121 1122 /** 1123 * プールしているインスタンスを取得する 1124 * 1125 * @param string $dsn データソース名 1126 * @return SC_Query|null 1127 */ 1128 static function getPoolInstance($dsn = '') { 1129 $key_str = serialize($dsn); 1130 if (isset(SC_Query_Ex::$arrPoolInstance[$key_str])) { 1131 return SC_Query_Ex::$arrPoolInstance[$key_str]; 1132 } 1133 } 1108 1134 }
Note: See TracChangeset
for help on using the changeset viewer.