From 6a9ea3ea1a7126a14d37aaa35f31a5288b2f0a4a Mon Sep 17 00:00:00 2001 From: fujimoto Date: Thu, 7 Apr 2005 09:37:47 +0000 Subject: [PATCH] =?utf8?q?-=20Ethna=5FDB=E3=82=AF=E3=83=A9=E3=82=B9?= =?utf8?q?=E3=82=92=E6=8A=BD=E8=B1=A1=E3=82=AF=E3=83=A9=E3=82=B9(=E6=89=B1?= =?utf8?q?=E3=81=84)=E3=81=A8=E3=81=97=E3=81=A6=E6=96=B0=E3=81=9F=E3=81=AB?= =?utf8?q?Ethna=5FDB=E3=82=AF=E3=83=A9=E3=82=B9=E3=82=92=E5=AE=9F=E8=A3=85?= =?utf8?q?=E3=81=97=E3=81=9FEthna=5FDB=5FPEAR=E3=82=AF=E3=83=A9=E3=82=B9?= =?utf8?q?=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- CHANGES | 2 + Ethna.php | 1 + class/DB/Ethna_DB_PEAR.php | 334 +++++++++++++++++++++++++++++++++++++++++++++ class/Ethna_AppManager.php | 2 +- class/Ethna_AppObject.php | 2 +- class/Ethna_Backend.php | 12 +- class/Ethna_Controller.php | 4 +- class/Ethna_DB.php | 231 +------------------------------ 8 files changed, 357 insertions(+), 231 deletions(-) create mode 100644 class/DB/Ethna_DB_PEAR.php diff --git a/CHANGES b/CHANGES index 4b637b5..9e47e4e 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,8 @@ - smarty_function_select¤Ë$empty°ú¿ô¤òÄɲà - mb_*¤ÎÊÑ´¹¸µ¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤ò¡¢EUC-JP¸ÇÄ꤫¤éÆâÉô¥¨¥ó¥³¡¼¥Ç¥£¥ó¥°¤ËÊѹ¹ - Ethna_Backend::begin(), Ethna_Backend::commit(), Ethna_Backend::rollback()¤òÇÑ»ß +- Ethna_Controller::getDB()¤òEthna_Controller::getDBType()¤ËÊѹ¹ +- Ethna_DB¥¯¥é¥¹¤òÃê¾Ý¥¯¥é¥¹(°·¤¤)¤È¤·¤Æ¿·¤¿¤ËEthna_DB¥¯¥é¥¹¤ò¼ÂÁõ¤·¤¿Ethna_DB_PEAR¥¯¥é¥¹¤òÄɲà *** bug fixes diff --git a/Ethna.php b/Ethna.php index fe3e221..5163416 100644 --- a/Ethna.php +++ b/Ethna.php @@ -55,6 +55,7 @@ include_once(ETHNA_BASE . '/class/Ethna_Config.php'); include_once(ETHNA_BASE . '/class/Ethna_Controller.php'); include_once(ETHNA_BASE . '/class/Ethna_ClassFactory.php'); include_once(ETHNA_BASE . '/class/Ethna_DB.php'); +include_once(ETHNA_BASE . '/class/DB/Ethna_DB_PEAR.php'); include_once(ETHNA_BASE . '/class/Ethna_Filter.php'); include_once(ETHNA_BASE . '/class/Ethna_I18N.php'); include_once(ETHNA_BASE . '/class/Ethna_LogWriter.php'); diff --git a/class/DB/Ethna_DB_PEAR.php b/class/DB/Ethna_DB_PEAR.php new file mode 100644 index 0000000..0eef1cb --- /dev/null +++ b/class/DB/Ethna_DB_PEAR.php @@ -0,0 +1,334 @@ + + * @license http://www.opensource.org/licenses/bsd-license.php The BSD License + * @package Ethna + * @version $Id$ + */ + +// {{{ Ethna_DB_PEAR +/** + * Ethna_DB¥¯¥é¥¹¤Î¼ÂÁõ(PEARÈÇ) + * + * @author Masaki Fujimoto + * @access public + * @package Ethna + */ +class Ethna_DB_PEAR +{ + /**#@+ + * @access private + */ + + /** @var object DB PEAR DB¥ª¥Ö¥¸¥§¥¯¥È */ + var $db; + + /** @var array ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó´ÉÍý¥¹¥¿¥Ã¥¯ */ + var $transaction = array(); + + + /** @var object Ethna_Logger ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È */ + var $logger; + + /** @var object Ethna_AppSQL SQL¥ª¥Ö¥¸¥§¥¯¥È */ + var $sql; + + /** @var string DB¥¿¥¤¥×(mysql, pgsql...) */ + var $type; + + /** @var string DSN */ + var $dsn; + + /** @var bool »ý³Àܳ¥Õ¥é¥° */ + var $persistent; + + /**#@-*/ + + + // {{{ Ethna_DB¥¯¥é¥¹¤Î¼ÂÁõ + /** + * Ethna_DB_PEAR¥¯¥é¥¹¤Î¥³¥ó¥¹¥È¥é¥¯¥¿ + * + * @access public + * @param object Ethna_Controller &$controller ¥³¥ó¥È¥í¡¼¥é¥ª¥Ö¥¸¥§¥¯¥È + * @param string $dsn DSN + * @param bool $persistent »ý³ÀܳÀßÄê + */ + function Ethna_DB_PEAR(&$controller, $dsn, $persistent) + { + $this->dsn = $dsn; + $this->persistent = $persistent; + $this->db = null; + $this->logger =& $controller->getLogger(); + $this->sql =& $controller->getSQL(); + + $dsninfo = DB::parseDSN($dsn); + $this->type = $dsninfo['phptype']; + } + + /** + * DB¤ËÀܳ¤¹¤ë + * + * @access public + * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼ + */ + function connect() + { + $this->db =& DB::connect($this->dsn, $this->persistent); + if (DB::isError($this->db)) { + $error = Ethna::raiseError('DBÀܳ¥¨¥é¡¼: %s', E_DB_CONNECT, $this->db->getUserInfo()); + $error->addUserInfo($this->db); + $this->db = null; + return $error; + } + + return 0; + } + + /** + * DBÀܳ¤òÀÚÃǤ¹¤ë + * + * @access public + */ + function disconnect() + { + if (is_null($this->db)) { + return; + } + $this->db->disconnect(); + } + + /** + * DBÀܳ¾õÂÖ¤òÊÖ¤¹ + * + * @access public + * @return bool true:Àµ¾ï false:¥¨¥é¡¼ + */ + function isValid() + { + if (is_null($this->db)) { + return false; + } else { + return true; + } + } + + /** + * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò³«»Ï¤¹¤ë + * + * @access public + * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼ + */ + function begin() + { + if (count($this->transaction) > 0) { + $this->transaction[] = true; + return 0; + } + + $r = $this->query('BEGIN;'); + if (Ethna::isError($r)) { + return $r; + } + $this->transaction[] = true; + + return 0; + } + + /** + * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤òÃæÃǤ¹¤ë + * + * @access public + * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼ + */ + function rollback() + { + if (count($this->transaction) == 0) { + return 0; + } + + // ¥í¡¼¥ë¥Ð¥Ã¥¯»þ¤Ï¥¹¥¿¥Ã¥¯¿ô¤Ë´Ø¤ï¤é¤º¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¥¯¥ê¥¢¤¹¤ë + $r = $this->query('ROLLBACK;'); + if (Ethna::isError($r)) { + return $r; + } + $this->transaction = array(); + + return 0; + } + + /** + * DB¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò½ªÎ»¤¹¤ë + * + * @access public + * @return mixed 0:Àµ¾ï½ªÎ» Ethna_Error:¥¨¥é¡¼ + */ + function commit() + { + if (count($this->transaction) == 0) { + return 0; + } else if (count($this->transaction) > 1) { + array_pop($this->transaction); + return 0; + } + + $r = $this->query('COMMIT;'); + if (Ethna::isError($r)) { + return $r; + } + array_pop($this->transaction); + + return 0; + } + // }}} + + // {{{ Ethna_AppObjectÏ¢·È¤Î¤¿¤á¤Î¼ÂÁõ + /** + * DB¥¿¥¤¥×¤òÊÖ¤¹ + * + * @access public + * @return string DB¥¿¥¤¥× + */ + function getType() + { + return $this->type; + } + + /** + * ¥¯¥¨¥ê¤òȯ¹Ô¤¹¤ë + * + * @access public + * @param string $query SQLʸ + * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼ + */ + function &query($query) + { + return $this->_query($query); + } + + /** + * ľ¶á¤ÎINSERT¤Ë¤è¤ëID¤ò¼èÆÀ¤¹¤ë + * + * ÀܳÃæ¤ÎDB¤¬mysql¤Ê¤émysql_insert_id()¤ÎÃͤòÊÖ¤¹ + * + * @access public + * @return mixed int:ľ¶á¤ÎINSERT¤Ë¤è¤êÀ¸À®¤µ¤ì¤¿ID null:̤¥µ¥Ý¡¼¥È + */ + function getInsertId() + { + if ($this->isValid() == false) { + return null; + } else if ($this->type == 'mysql') { + return mysql_insert_id($this->db->connection); + } + + return null; + } + + /** + * ľ¶á¤Î¥¯¥¨¥ê¤Ë¤è¤ë¹¹¿·¹Ô¿ô¤ò¼èÆÀ¤¹¤ë + * + * @access public + * @return int ¹¹¿·¹Ô¿ô + */ + function affectedRows() + { + return $this->db->affectedRows(); + } + // }}} + + // {{{ Ethna_DB_PEARÆȼ«¤Î¼ÂÁõ + /** + * SQLʸ»ØÄꥯ¥¨¥ê¤òȯ¹Ô¤¹¤ë + * + * @access public + * @param string $sqlid SQL-ID(+°ú¿ô) + * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼ + */ + function &sqlquery($sqlid) + { + $args = func_get_args(); + array_shift($args); + $query = $this->sql->get($sqlid, $args); + + return $this->_query($query); + } + + /** + * SQLʸ¤ò¼èÆÀ¤¹¤ë + * + * @access public + * @param string $sqlid SQL-ID + * @return string SQLʸ + */ + function sql($sqlid) + { + $args = func_get_args(); + array_shift($args); + $query = $this->sql->get($sqlid, $args); + + return $query; + } + + /** + * ¥Æ¡¼¥Ö¥ë¤ò¥í¥Ã¥¯¤¹¤ë + * + * @access public + * @param mixed ¥í¥Ã¥¯Âоݥơ¼¥Ö¥ë̾ + * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼ + */ + function lock($tables) + { + $this->message = null; + + $sql = ""; + foreach (to_array($tables) as $table) { + if ($sql != "") { + $sql .= ", "; + } + $sql .= "$table WRITE"; + } + + return $this->query("LOCK TABLES $sql"); + } + + /** + * ¥Æ¡¼¥Ö¥ë¤Î¥í¥Ã¥¯¤ò²òÊü¤¹¤ë + * + * @access public + * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼ + */ + function unlock() + { + $this->message = null; + return $this->query("UNLOCK TABLES"); + } + + /** + * ¥¯¥¨¥ê¤òȯ¹Ô¤¹¤ë + * + * @access private + * @param string $query SQLʸ + * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼ + */ + function &_query($query) + { + $this->logger->log(LOG_DEBUG, "$query"); + $r =& $this->db->query($query); + if (DB::isError($r)) { + if ($r->getCode() == DB_ERROR_ALREADY_EXISTS) { + $error = Ethna::raiseNotice('¥æ¥Ë¡¼¥¯À©Ì󥨥顼 SQL[%s]', E_DB_DUPENT, $query, $this->db->errorNative(), $r->getUserInfo()); + } else { + $error = Ethna::raiseError('¥¯¥¨¥ê¥¨¥é¡¼ SQL[%s] CODE[%d] MESSAGE[%s]', E_DB_QUERY, $query, $this->db->errorNative(), $r->getUserInfo()); + } + return $error; + } + return $r; + } + // }}} +} +// }}} +?> diff --git a/class/Ethna_AppManager.php b/class/Ethna_AppManager.php index f8a6a92..4722102 100644 --- a/class/Ethna_AppManager.php +++ b/class/Ethna_AppManager.php @@ -81,7 +81,7 @@ class Ethna_AppManager $this->af =& $this->action_form; $this->session =& $backend->getSession(); - $db_list = $backend->getDBlist(); + $db_list = $backend->getDBList(); if (Ethna::isError($db_list) == false) { foreach ($db_list as $elt) { $varname = $elt['varname']; diff --git a/class/Ethna_AppObject.php b/class/Ethna_AppObject.php index 86eac69..10e332b 100644 --- a/class/Ethna_AppObject.php +++ b/class/Ethna_AppObject.php @@ -82,7 +82,7 @@ class Ethna_AppObject $this->af =& $this->action_form; $this->session =& $backend->getSession(); - $db_list = $backend->getDBlist(); + $db_list = $backend->getDBList(); if (Ethna::isError($db_list) == false) { foreach ($db_list as $elt) { $varname = $elt['varname']; diff --git a/class/Ethna_Backend.php b/class/Ethna_Backend.php index fed8bd1..99af323 100644 --- a/class/Ethna_Backend.php +++ b/class/Ethna_Backend.php @@ -349,6 +349,12 @@ class Ethna_Backend $class_factory =& $this->controller->getClassFactory(); $db_class_name = $class_factory->getObjectName('db'); + + // BC: Ethna_DB -> Ethna_DB_PEAR + if ($db_class_name == 'Ethna_DB') { + $db_class_name = 'Ethna_DB_PEAR'; + } + $this->db[$key] =& new $db_class_name($this->controller, $dsn, $dsn_persistent); $r = $this->db[$key]->connect(); if (Ethna::isError($r)) { @@ -368,7 +374,7 @@ class Ethna_Backend * @return mixed array:Ethna_DB¥ª¥Ö¥¸¥§¥¯¥È¤Î°ìÍ÷ Ethan_Error:(¤¤¤º¤ì¤«°ì¤Ä°Ê¾å¤ÎÀܳ¤Ç)¥¨¥é¡¼ * @todo respect access controlls */ - function getDBlist() + function getDBList() { $r = array(); foreach ($this->controller->db as $key => $value) { @@ -404,7 +410,7 @@ class Ethna_Backend } /** - * »ØÄꤵ¤ì¤¿DB¼ïÊ̤ËÂбþ¤¹¤ëDB¥ª¥Ö¥¸¥§¥¯¥È¤ò³ÊǼ¤·¤¿¥á¥ó¥ÐÊÑ¿ô¤ò¼èÆÀ¤¹¤ë + * »ØÄꤵ¤ì¤¿DB¼ïÊ̤ËÂбþ¤¹¤ë(Åö³ºDB¥ª¥Ö¥¸¥§¥¯¥È¤ò³ÊǼ¤¹¤ë¤¿¤á¤Î)¥á¥ó¥ÐÊÑ¿ô̾¤ò¼èÆÀ¤¹¤ë * * @access private * @param string $type DB¼ïÊÌ @@ -412,7 +418,7 @@ class Ethna_Backend */ function &_getDB($type = "") { - $r = $this->controller->getDB($type); + $r = $this->controller->getDBType($type); if (is_null($r)) { return Ethna::raiseError(E_DB_INVALIDTYPE, "̤ÄêµÁ¤ÎDB¼ïÊÌ[%s]", $type); } diff --git a/class/Ethna_Controller.php b/class/Ethna_Controller.php index 14b0512..02be228 100644 --- a/class/Ethna_Controller.php +++ b/class/Ethna_Controller.php @@ -339,10 +339,10 @@ class Ethna_Controller * DBÀßÄê¤òÊÖ¤¹ * * @access public - * @param string $key DB¥¿¥¤¥×("r", ...) + * @param string $key DB¥­¡¼("r", ...) * @return string $key¤ËÂбþ¤¹¤ëDB¼ïÊÌÄêµÁ(ÀßÄ̵꤬¤¤¾ì¹ç¤Ïnull) */ - function getDB($key) + function getDBType($key) { if (isset($this->db[$key]) == false) { return null; diff --git a/class/Ethna_DB.php b/class/Ethna_DB.php index 641167b..a721921 100644 --- a/class/Ethna_DB.php +++ b/class/Ethna_DB.php @@ -11,7 +11,10 @@ // {{{ Ethna_DB /** - * DB¥¯¥é¥¹ + * EthnaÍÑDBÃê¾Ý¥¯¥é¥¹ + * + * Ethna¤Î¥Õ¥ì¡¼¥à¥ï¡¼¥¯¤ÇDB¥ª¥Ö¥¸¥§¥¯¥È¤ò°·¤¦¤¿¤á¤ÎÃê¾Ý¥¯¥é¥¹ + * (¤Î¤Ä¤â¤ê...¤¢¤¡¤¹¤Ð¤é¤·¤­PHP 4) * * @author Masaki Fujimoto * @access public @@ -23,24 +26,9 @@ class Ethna_DB * @access private */ - /** @var object DB PEAR DB¥ª¥Ö¥¸¥§¥¯¥È */ + /** @var object DB DB¥ª¥Ö¥¸¥§¥¯¥È */ var $db; - /** @var object Ethna_Logger ¥í¥°¥ª¥Ö¥¸¥§¥¯¥È */ - var $logger; - - /** @var object Ethna_AppSQL SQL¥ª¥Ö¥¸¥§¥¯¥È */ - var $sql; - - /** @var string DB¥¿¥¤¥×(mysql, pgsql...) */ - var $type; - - /** @var string DSN */ - var $dsn; - - /** @var bool »ý³Àܳ¥Õ¥é¥° */ - var $persistent; - /** @var array ¥È¥é¥ó¥¶¥¯¥·¥ç¥ó´ÉÍý¥¹¥¿¥Ã¥¯ */ var $transaction = array(); @@ -53,18 +41,10 @@ class Ethna_DB * @access public * @param object Ethna_Controller &$controller ¥³¥ó¥È¥í¡¼¥é¥ª¥Ö¥¸¥§¥¯¥È * @param string $dsn DSN - * @param bool $persistent »ý³ÀܳÀßÄê + * @param bool $persistent »ý³ÀܳÀßÄê */ function Ethna_DB(&$controller, $dsn, $persistent) { - $this->dsn = $dsn; - $this->persistent = $persistent; - $this->db = null; - $this->logger =& $controller->getLogger(); - $this->sql =& $controller->getSQL(); - - $dsninfo = DB::parseDSN($dsn); - $this->type = $dsninfo['phptype']; } /** @@ -75,15 +55,6 @@ class Ethna_DB */ function connect() { - $this->db =& DB::connect($this->dsn, $this->persistent); - if (DB::isError($this->db)) { - $error = Ethna::raiseError('DBÀܳ¥¨¥é¡¼: %s', E_DB_CONNECT, $this->db->getUserInfo()); - $error->addUserInfo($this->db); - $this->db = null; - return $error; - } - - return 0; } /** @@ -93,144 +64,16 @@ class Ethna_DB */ function disconnect() { - if (is_null($this->db)) { - return; - } - $this->db->disconnect(); } /** * DBÀܳ¾õÂÖ¤òÊÖ¤¹ * * @access public - * @return bool true:Àµ¾ï false:¥¨¥é¡¼ + * @return bool true:Àµ¾ï(ÀܳºÑ¤ß) false:¥¨¥é¡¼/̤Àܳ */ function isValid() { - if (is_null($this->db)) { - return false; - } else { - return true; - } - } - - /** - * DB¥¿¥¤¥×¤òÊÖ¤¹ - * - * @access public - * @return string DB¥¿¥¤¥× - */ - function getType() - { - return $this->type; - } - - /** - * ¥¯¥¨¥ê¤òȯ¹Ô¤¹¤ë - * - * @access public - * @param string $query SQLʸ - * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼ - */ - function &query($query) - { - return $this->_query($query); - } - - /** - * SQLʸ»ØÄꥯ¥¨¥ê¤òȯ¹Ô¤¹¤ë - * - * @access public - * @param string $sqlid SQL-ID(+°ú¿ô) - * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼ - */ - function &sqlquery($sqlid) - { - $args = func_get_args(); - array_shift($args); - $query = $this->sql->get($sqlid, $args); - - return $this->_query($query); - } - - /** - * SQLʸ¤ò¼èÆÀ¤¹¤ë - * - * @access public - * @param string $sqlid SQL-ID - * @return string SQLʸ - */ - function sql($sqlid) - { - $args = func_get_args(); - array_shift($args); - $query = $this->sql->get($sqlid, $args); - - return $query; - } - - /** - * ľ¶á¤ÎINSERT¤Ë¤è¤ëID¤ò¼èÆÀ¤¹¤ë - * - * ÀܳÃæ¤ÎDB¤¬mysql¤Ê¤émysql_insert_id()¤ÎÃͤòÊÖ¤¹ - * - * @access public - * @return mixed int:ľ¶á¤ÎINSERT¤Ë¤è¤êÀ¸À®¤µ¤ì¤¿ID null:̤¥µ¥Ý¡¼¥È - */ - function getInsertId() - { - if ($this->isValid() == false) { - return null; - } else if ($this->type == 'mysql') { - return mysql_insert_id($this->db->connection); - } - - return null; - } - - /** - * ľ¶á¤Î¥¯¥¨¥ê¤Ë¤è¤ë¹¹¿·¹Ô¿ô¤ò¼èÆÀ¤¹¤ë - * - * @access public - * @return int ¹¹¿·¹Ô¿ô - */ - function affectedRows() - { - return $this->db->affectedRows(); - } - - /** - * ¥Æ¡¼¥Ö¥ë¤ò¥í¥Ã¥¯¤¹¤ë - * - * @access public - * @param mixed ¥í¥Ã¥¯Âоݥơ¼¥Ö¥ë̾ - * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼ - */ - function lock($tables) - { - $this->message = null; - - $sql = ""; - foreach (to_array($tables) as $table) { - if ($sql != "") { - $sql .= ", "; - } - $sql .= "$table WRITE"; - } - - return $this->query("LOCK TABLES $sql"); - } - - /** - * ¥Æ¡¼¥Ö¥ë¤Î¥í¥Ã¥¯¤ò²òÊü¤¹¤ë - * - * @access public - * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼ - */ - function unlock() - { - $this->message = null; - return $this->query("UNLOCK TABLES"); } /** @@ -241,18 +84,6 @@ class Ethna_DB */ function begin() { - if (count($this->transaction) > 0) { - $this->transaction[] = true; - return 0; - } - - $r = $this->query('BEGIN;'); - if (Ethna::isError($r)) { - return $r; - } - $this->transaction[] = true; - - return 0; } /** @@ -263,18 +94,6 @@ class Ethna_DB */ function rollback() { - if (count($this->transaction) == 0) { - return 0; - } - - // ¥í¡¼¥ë¥Ð¥Ã¥¯»þ¤Ï¥¹¥¿¥Ã¥¯¿ô¤Ë´Ø¤ï¤é¤º¥È¥é¥ó¥¶¥¯¥·¥ç¥ó¤ò¥¯¥ê¥¢¤¹¤ë - $r = $this->query('ROLLBACK;'); - if (Ethna::isError($r)) { - return $r; - } - $this->transaction = array(); - - return 0; } /** @@ -285,42 +104,6 @@ class Ethna_DB */ function commit() { - if (count($this->transaction) == 0) { - return 0; - } else if (count($this->transaction) > 1) { - array_pop($this->transaction); - return 0; - } - - $r = $this->query('COMMIT;'); - if (Ethna::isError($r)) { - return $r; - } - array_pop($this->transaction); - - return 0; - } - - /** - * ¥¯¥¨¥ê¤òȯ¹Ô¤¹¤ë - * - * @access private - * @param string $query SQLʸ - * @return mixed DB_Result:·ë²Ì¥ª¥Ö¥¸¥§¥¯¥È Ethna_Error:¥¨¥é¡¼ - */ - function &_query($query) - { - $this->logger->log(LOG_DEBUG, "$query"); - $r =& $this->db->query($query); - if (DB::isError($r)) { - if ($r->getCode() == DB_ERROR_ALREADY_EXISTS) { - $error = Ethna::raiseNotice('¥æ¥Ë¡¼¥¯À©Ì󥨥顼 SQL[%s]', E_DB_DUPENT, $query, $this->db->errorNative(), $r->getUserInfo()); - } else { - $error = Ethna::raiseError('¥¯¥¨¥ê¥¨¥é¡¼ SQL[%s] CODE[%d] MESSAGE[%s]', E_DB_QUERY, $query, $this->db->errorNative(), $r->getUserInfo()); - } - return $error; - } - return $r; } } // }}} -- 2.11.0