/** * Action a report drop down * * @return @e void */ protected function _multiManage() { $merge_id = $this->request['sessionID'] = intval($this->request['merge_id']); $mergeOption = trim($this->request['mergeOption']); $items = is_array($_POST['changeIds']) ? IPSLib::cleanIntArray(array_keys($_POST['changeIds'])) : array(); /* Fetch session and check */ $session = $this->skinFunctions->fetchSession($merge_id); if ($session === FALSE) { $this->registry->output->showError($this->lang->words['sd_nosession']); } /* Got items? */ if (count($items)) { /* Process. I love pointless comments */ switch ($mergeOption) { case 'resolve_custom': $this->skinFunctions->resolveConflict($items, 'custom'); break; case 'resolve_new': $this->skinFunctions->resolveConflict($items, 'new'); break; case 'commit': $this->skinFunctions->commit($items); break; case 'revert': $this->skinFunctions->revert($items); break; } } /* Flush CDN */ $this->skinFunctions->flushipscdn(); /* Throw it out */ $this->registry->output->global_message = $this->lang->words['skindiff_okmsg']; return $this->_viewReport(); }
/** * Finalizes all add/deletes made to the index * * @return object */ public function commit() { $this->_beforeCommit(); $result = $this->_client->commit(); $this->_afterCommit(); return $result; }
/** * Down all migrations * * @return mixed String if reseted or false if fail * @access public */ function reset() { if ($this->down(true)) { if (isset($this->params['force'])) { App::import('Vendor', $this->_pluginName . '.Migration'); $migration = new Migration($this); $tables = $this->db->listSources(); if (!empty($tables)) { $this->db->begin($migration); foreach ($tables as $table) { if ($table == $this->_schemaTable) { continue; } if (!$migration->dropTable($table)) { $this->db->rollback($migration); $this->err(__d('migrations', 'Can not execute drop of all tables.', true)); return false; } } $this->db->commit($migration); } } return __d('migrations', 'Resetted.', true) . "\n"; } return false; }
/** * Execute Install and Uninstall methods * * @param string $command Can be 'up' or 'down' * @param string $callback Name of callback function * @return boolean * @access protected */ function _exec($command, $callback) { $this->__error = false; if (!method_exists($this, $command)) { $this->out(String::insert(__d('migrations', '> Method ":method" not implemented. Skipping...', true), array('method' => $command))); return true; } $method = 'before' . $callback; if (method_exists($this, $method)) { if (!$this->{$method}()) { return false; } } $ok = $this->_db->begin($this->__fakeSchema); $this->{$command}(); if ($this->stopOnError) { if ($this->__error) { $ok = false; } } if ($ok) { $this->_db->commit($this->__fakeSchema); } else { $this->_db->rollback($this->__fakeSchema); } $method = 'after' . $callback; if (method_exists($this, $method)) { $this->{$method}($ok); } return $ok; }
/** This method commits the transaction @access public @throws PDOException object @return void */ public function commit() { try { $this->DBHandler->commit(); } catch (PDOException $e) { throw $e; } }
/** * 提交事务处理 * * @access public * @return boolean */ public function commit() { if ($this->Transactions == true) { if ($this->db_link->commit()) { $this->Transactions = false; } } return true; }
/** * Finalizes all add/deletes made to the index * * @return object|bool */ public function commit() { if ($this->_holdCommit) { return false; } $this->_beforeCommit(); $result = $this->_client->commit(); $this->_afterCommit(); return $result; }
/** * (non-PHPdoc) * @see PDO::commit() */ public function commit() { if ($this->pdo->inTransaction) { if ($this->canEndTransaction) { $this->pdo->commit(); } return true; } else { return false; } }
/** * 提交事务处理 * * @access public * * @return boolean */ public function commit() { //当事务处理开启时 if ($this->_transactions == true) { if ($this->_dbLink->commit()) { $this->_transactions = false; //SQL日志记录 $this->_logQuery('COMMIT'); } } return true; }
/** * Destructor * * @access public * @return void */ public function __destruct() { // Create new session ID if ($this->regenerate_id) { session_regenerate_id(true); } // Close session session_write_close(); if ($this->transaction) { $this->db->commit(); } }
public static function commit() { try { if (!self::$instance instanceof \PDO) { throw new \PDOException(self::$exception['no-instance']); } if (!self::$instance->commit()) { throw new \PDOException(current(self::$instance->errorInfo()) . ' ' . end(self::$instance->errorInfo())); } } catch (\PDOException $e) { self::stackTrace($e); } }
/** * Zatwierdzenie SQL-i głównego bloku transakcji, gdy $this->transOff == 1 * oraz gdy nie wystąpiły żadne błędy SQL-owe. * * @param boolean $commit * true - monitoruje błędy SQL, * false - wymuszenie odrzucenia wszystkich SQL-i w transakcji * * @throws MK_Db_Exception * @return bool */ public function transComplete($commit = true) { // Zwrócenie szczegółowego komunikatu w konsoli FireBug-a if (MK_DEBUG_FIREPHP) { $this->fireBugSqlDump("transComplete(" . ($commit ? 'true' : 'false') . ")"); } $_transCount = MK_Db_PDO_Singleton::transCount(); if ($_transCount > 1) { // Transakcja jest w innej transakcji, zamykanie bloku transakcji MK_Db_PDO_Singleton::transCount(-1); return true; } else { if ($_transCount == 1) { // Jeśli transakcja nie została przerwana, to należy zamknąć logi if ($commit == true) { if (class_exists('TableLogsDb')) { /** @noinspection PhpUndefinedClassInspection */ $tableLogsDb = new TableLogsDb(); /** @noinspection PhpUndefinedMethodInspection */ $tableLogsDb->closeConnectionForTableLog(); } } // Transakcja jest do zamknięcia MK_Db_PDO_Singleton::transCount(0, true); } else { if ($_transCount == 0) { // Transakcja nie była uruchomiona return false; } else { // Do takiego błędu nie powinno w ogóle dojść, ale należałoby się przed tym zabezpieczyć... throw new MK_Db_Exception('Transakcja wywołała niespodziewany błąd. Poinformuj administratora systemu.'); } } } /** * true - COMMIT * false - ROLLBACK */ if ($commit && MK_Db_PDO_Singleton::transOk()) { if (!$this->db->commit()) { MK_Db_PDO_Singleton::transOk(false); throw new MK_Db_Exception('Transakcja nie powiodła się'); } } else { MK_Db_PDO_Singleton::transOk(false); $this->db->rollBack(); } return MK_Db_PDO_Singleton::transOk(); }
/** * Write data associated with a given unique ID to container * * @access public * @param string $uniqueId IP address or other unique ID. * @param array $data The data associated with a given unique ID. * @return void * @throws HTTP_FloodControl_Exception if an error occured during writing process. */ public function write($uniqueId, $data) { $quotedTblName = $this->_db->quoteIdentifier($this->_options['table']); $this->_db->beginTransaction(); $query = sprintf("DELETE FROM %s WHERE unique_id = %s", $quotedTblName, $this->_db->quote($uniqueId, 'text')); $result = $this->_db->exec($query); if (PEAR::isError($result)) { throw new HTTP_FloodControl_Exception($result->getMessage(), $result->getCode()); } $query = sprintf("INSERT INTO %s (unique_id, data, access) VALUES (%s, %s, %d)", $quotedTblName, $this->_db->quote($uniqueId, 'text'), $this->_db->quote(serialize($data), 'text'), time()); $result = $this->_db->exec($query); if (PEAR::isError($result)) { $this->_db->rollback(); throw new HTTP_FloodControl_Exception($result->getMessage(), $result->getCode()); } $this->_db->commit(); }
/** * Flush the write cache to db * * @access public */ public function flushWriteCache() { if ($this->writeCacheData !== null) { $trans = $this->db->beginTransaction(); /** can't create a prepared sql because some parameters can be null ??? */ foreach ($this->writeCacheData as $key1 => $value1) { foreach ($value1 as $key2 => $value) { $fields = array('do_id' => $this->absOrNull($this->do_id), 'app_id' => $this->absOrNull($this->app_id), 'us_id' => $this->absOrNull($this->us_id), 'se_section' => $key1, 'se_param' => $key2); $sql = "UPDATE " . $this->options['settings_table'] . " SET \n" . " se_value = " . $this->db->quote($this->writeCacheData[$key1][$key2]) . " \n" . "WHERE \n" . $this->array2Where($fields); $affectedRows = $this->db->exec($sql); $this->checkDBError($affectedRows, __LINE__); if ($affectedRows == 0) { $sql = "INSERT INTO " . $this->options['settings_table'] . " " . " (do_id, app_id, us_id,se_section, se_param, se_value) " . "VALUES " . " (" . $this->db->quote($this->absOrNull($this->do_id)) . ", " . $this->db->quote($this->absOrNull($this->app_id)) . ", " . $this->db->quote($this->absOrNull($this->us_id)) . ", " . $this->db->quote($key1) . ", " . $this->db->quote($key2) . ", " . $this->db->quote($this->writeCacheData[$key1][$key2]) . ")"; $res = $this->db->exec($sql); $this->checkDBError($res, __LINE__); } } } $trans = $this->db->commit(); $this->writeCacheData = null; } }
/** * Delete a node and it's children * * @param int $keyValue Primary key of node * @return bool If it happend or not */ public function deleteNode($keyValue) { try { $this->_pdoInstance->beginTransaction(); $this->_lockTables(); $node = $this->getSimpleNode($keyValue); // Delete the node $deleteSql = "DELETE FROM `" . $this->getTable() . "`\n WHERE\n `" . $this->getLeftColumn() . "`\n BETWEEN '" . $node[$this->getLeftColumn()] . "'\n AND '" . $node[$this->getRightColumn()] . "'"; $this->_pdoInstance->exec($deleteSql); // Update left values of other nodes $updateSql = "UPDATE `" . $this->getTable() . "`\n SET `" . $this->getLeftColumn() . "` = `" . $this->getLeftColumn() . "` - ROUND(\n ('" . $node[$this->getRightColumn()] . "' - '" . $node[$this->getLeftColumn()] . "' + 1)\n )\n WHERE `" . $this->getLeftColumn() . "` > '" . $node[$this->getRightColumn()] . "'"; $this->_pdoInstance->exec($updateSql); // Update right values of other nodes $updateSql = "UPDATE `" . $this->getTable() . "`\n SET `" . $this->getRightColumn() . "` = `" . $this->getRightColumn() . "` - ROUND(\n ('" . $node[$this->getRightColumn()] . "' - '" . $node[$this->getLeftColumn()] . "' + 1)\n )\n WHERE `" . $this->getRightColumn() . "` > '" . $node[$this->getRightColumn()] . "'"; $this->_pdoInstance->exec($updateSql); $this->_pdoInstance->exec("UNLOCK TABLES"); $this->_pdoInstance->commit(); return true; } catch (\PDOException $e) { $this->_pdoInstance->rollBack(); return false; } }
/** * Delete element with number $ID from the tree and all it childret. * * @param integer $ID Number of element * @param array $condition Array structure: array('and' => array('id = 0', 'id2 >= 3'), 'or' => array('sec = \'www\'', 'sec2 <> \'erere\'')), etc where array key - condition (AND, OR, etc), value - condition string * @return bool TRUE if successful, FALSE otherwise. */ function DeleteAll($ID, $condition = '') { $node_info = $this->GetNodeInfo($ID); if (FALSE === $node_info) { return FALSE; } list($leftId, $rightId) = $node_info; if (!empty($condition)) { $condition = $this->_PrepareCondition($condition); } $sql = 'DELETE FROM ' . $this->table . ' WHERE ' . $this->table_left . ' BETWEEN ' . $leftId . ' AND ' . $rightId; $this->db->beginTransaction(); try { $res = $this->db->query($sql); $deltaId = $rightId - $leftId + 1; $sql = 'UPDATE ' . $this->table . ' SET ' . $this->table_left . ' = CASE WHEN ' . $this->table_left . ' > ' . $leftId . ' THEN ' . $this->table_left . ' - ' . $deltaId . ' ELSE ' . $this->table_left . ' END, ' . $this->table_right . ' = CASE WHEN ' . $this->table_right . ' > ' . $leftId . ' THEN ' . $this->table_right . ' - ' . $deltaId . ' ELSE ' . $this->table_right . ' END ' . 'WHERE ' . $this->table_right . ' > ' . $rightId; $sql .= $condition; $res = $this->db->query($sql); $this->db->commit(); return TRUE; } catch (Exception $e) { $this->db->rollBack(); } }
/** * Handled pending contribution status * @param array $objects * @param object $transaction * @return boolean */ function pending(&$objects, &$transaction) { $transaction->commit(); CRM_Core_Error::debug_log_message("returning since contribution status is pending"); echo "Success: Returning since contribution status is pending<p>"; return TRUE; }
/** * 回滚一个事务 * @access public */ public function commit() { $this->connect(); return $this->link->commit(); }
/** * Create user * * @param object $user stdclass or User object for the usr table * @param array $profile profile field/values to set * @param string $institution Institution the user should joined to * @param stdclass $remoteauth authinstance record for a remote authinstance * @param string $remotename username on the remote site * @return integer id of the new user */ function create_user($user, $profile = array(), $institution = null, $remoteauth = null, $remotename = null) { db_begin(); if ($user instanceof User) { $user->create(); $user->quota_init(); $user->commit(); $user = $user->to_stdclass(); } else { $user->ctime = db_format_timestamp(time()); if (empty($user->quota)) { $user->quota = get_config_plugin('artefact', 'file', 'defaultquota'); } $user->id = insert_record('usr', $user, 'id', true); } // Bypass access check for 'copynewuser' institution/site views, because this user may not be logged in yet $user->newuser = true; if (isset($user->email) && $user->email != '') { set_profile_field($user->id, 'email', $user->email); } if (isset($user->firstname) && $user->firstname != '') { set_profile_field($user->id, 'firstname', $user->firstname); } if (isset($user->lastname) && $user->lastname != '') { set_profile_field($user->id, 'lastname', $user->lastname); } foreach ($profile as $k => $v) { if (in_array($k, array('firstname', 'lastname', 'email'))) { continue; } set_profile_field($user->id, $k, $v); } if (!empty($institution) && $institution != 'mahara') { if (is_string($institution)) { $institution = new Institution($institution); } if ($institution->name != 'mahara') { $institution->addUserAsMember($user); // uses $user->newuser } } if (!empty($remoteauth) && $remoteauth->authname != 'internal') { if (isset($remotename) && strlen($remotename) > 0) { $un = $remotename; } else { $un = $user->username; } delete_records('auth_remote_user', 'authinstance', $user->authinstance, 'remoteusername', $un); insert_record('auth_remote_user', (object) array('authinstance' => $user->authinstance, 'remoteusername' => $un, 'localusr' => $user->id)); } // Copy site views to the new user's profile $checkviewaccess = !$user->newuser; $userobj = new User(); $userobj->find_by_id($user->id); $userobj->copy_views(get_column('view', 'id', 'institution', 'mahara', 'copynewuser', 1), $checkviewaccess); handle_event('createuser', $user); db_commit(); return $user->id; }
/** * 規格データをコピーする * * @param array $arrList フォーム入力パラメーター配列 * @param object $objQuery SC_Queryインスタンス * @return boolean エラーフラグ */ function lfCopyProductClass($arrList, &$objQuery) { // 複製元のdtb_products_classを取得(規格なしのため、1件のみの取得) $col = '*'; $table = 'dtb_products_class'; $where = 'product_id = ?'; $arrProductClass = $objQuery->select($col, $table, $where, array($arrList['copy_product_id'])); //トランザクション開始 $objQuery->begin(); $err_flag = false; //非編集項目は複製、編集項目は上書きして登録 foreach ($arrProductClass as $records) { foreach ($records as $key => $value) { if (isset($arrList[$key])) { switch ($key) { case 'stock_unlimited': $records[$key] = (int) $arrList[$key]; break; default: $records[$key] = $arrList[$key]; break; } } } $records['product_class_id'] = $objQuery->nextVal('dtb_products_class_product_class_id'); $records['update_date'] = 'CURRENT_TIMESTAMP'; $records['create_date'] = 'CURRENT_TIMESTAMP'; $objQuery->insert($table, $records); //エラー発生時は中断 if ($objQuery->isError()) { $err_flag = true; continue; } } //トランザクション終了 if ($err_flag) { $objQuery->rollback(); } else { $objQuery->commit(); } return !$err_flag; }
/** * 事务处理:提交事务处理 * * @access public * @return boolean */ public function commit() { return $this->_master->commit(); }
/** * Commit * * @access public * @return void */ public function commit() { $this->dbh->commit(); }
/** * Create user * * @param object $user stdclass or User object for the usr table * @param array $profile profile field/values to set * @param string|object $institution Institution the user should joined to (name or Institution object) * @param bool $remoteauth authinstance record for a remote authinstance * @param string $remotename username on the remote site * @param array $accountprefs user account preferences to set * @return integer id of the new user */ function create_user($user, $profile = array(), $institution = null, $remoteauth = null, $remotename = null, $accountprefs = array(), $quickhash = false) { db_begin(); if ($user instanceof User) { $user->create(); $user->quota_init(); $user->commit(); $user = $user->to_stdclass(); } else { $user->ctime = db_format_timestamp(time()); // Ensure this user has a profile urlid if (get_config('cleanurls') && (!isset($user->urlid) || is_null($user->urlid))) { $user->urlid = generate_urlid($user->username, get_config('cleanurluserdefault'), 3, 30); $user->urlid = get_new_profile_urlid($user->urlid); } if (empty($user->quota)) { $user->quota = get_config_plugin('artefact', 'file', 'defaultquota'); } if (get_config('defaultaccountlifetime')) { // we need to set the user expiry to the site default one $user->expiry = date('Y-m-d', mktime(0, 0, 0, date('m'), date('d'), date('Y')) + (int) get_config('defaultaccountlifetime')); } $user->id = insert_record('usr', $user, 'id', true); } if (isset($user->email) && $user->email != '') { set_profile_field($user->id, 'email', $user->email, TRUE); } if (isset($user->firstname) && $user->firstname != '') { set_profile_field($user->id, 'firstname', $user->firstname, TRUE); } if (isset($user->lastname) && $user->lastname != '') { set_profile_field($user->id, 'lastname', $user->lastname, TRUE); } foreach ($profile as $k => $v) { if (in_array($k, array('firstname', 'lastname', 'email'))) { continue; } set_profile_field($user->id, $k, $v, TRUE); } if (!empty($institution)) { if (is_string($institution)) { $institution = new Institution($institution); } if ($institution->name != 'mahara') { $institution->addUserAsMember($user); // uses $user->newuser if (empty($accountprefs['licensedefault'])) { $accountprefs['licensedefault'] = LICENSE_INSTITUTION_DEFAULT; } } } $authobj = get_record('auth_instance', 'id', $user->authinstance); $authinstance = AuthFactory::create($authobj->id); // For legacy compatibility purposes, we'll also put the remote auth on there if it has been // specifically requested. if ($authinstance->needs_remote_username() || !empty($remoteauth)) { if (isset($remotename) && strlen($remotename) > 0) { $un = $remotename; } else { $un = $user->username; } // remote username must not already exist if (record_exists('auth_remote_user', 'remoteusername', $un, 'authinstance', $user->authinstance)) { throw new InvalidArgumentException("user_create: remoteusername already exists: ({$un}, {$user->authinstance})"); } insert_record('auth_remote_user', (object) array('authinstance' => $user->authinstance, 'remoteusername' => $un, 'localusr' => $user->id)); } // Set account preferences if (!empty($accountprefs)) { $expectedprefs = expected_account_preferences(); foreach ($expectedprefs as $eprefkey => $epref) { if (isset($accountprefs[$eprefkey]) && $accountprefs[$eprefkey] != $epref) { set_account_preference($user->id, $eprefkey, $accountprefs[$eprefkey]); } } } // Copy site views and collections to the new user's profile $userobj = new User(); $userobj->find_by_id($user->id); $userobj->copy_site_views_collections_to_new_user(); reset_password($user, false, $quickhash); handle_event('createuser', $user); db_commit(); return $user->id; }
/** * Return news article text * @since Version 3.0.1 * @version 3.4 * @param int $id * @return mixed */ public function fetch($id = false) { if ($id) { $this->id = $id; } if (!$this->id) { throw new Exception("Cannot fetch news article - no ID given"); return false; } $return = false; $mckey = __METHOD__ . "-" . $this->id; $mcexp = strtotime("+1 hour"); /* if ($this->pending === false && $this->memcache && $return = $this->memcache->get($mckey)) { // Do nothing printArray($return);die; } else { */ if ($this->db instanceof \sql_db) { if ($this->pending == true) { // Get story from pending table $query = "SELECT u.username, 0 AS sent_to_fb, p.geo_lat, p.geo_lon, p.qid as sid, p.uname as informant, p.subject as title, p.story as hometext, p.storyext as bodytext, p.topic, p.source, t.topicname, t.topicimage, t.topictext, p.timestamp as time FROM nuke_users u, nuke_queue p, nuke_topics t WHERE p.topic = t.topicid AND p.uid = u.user_id AND p.qid = '" . $this->db->real_escape_string($this->id) . "'"; $table = "pending"; } else { $query = "SELECT s.*, t.topicname, t.topicimage, t.topictext, t.topicid FROM nuke_stories s, nuke_topics t WHERE s.topic = t.topicid AND s.sid = '" . $this->db->real_escape_string($this->id) . "'"; $table = "published"; } if ($rs = $this->db->query($query)) { if ($rs->num_rows == 0) { throw new Exception("Cannot fetch " . $table . " article ID " . $this->id . " - no story found"); return false; } $return = $rs->fetch_assoc(); if ($this->pending === false && $this->memcache) { $this->memcache->set($mckey, $return, $mcexp); } } } else { if ($this->pending == true) { $query = "SELECT q.qid AS sid, q.uid AS user_id, u.username, q.subject AS title, q.story AS hometext, q.storyext AS bodytext, q.timestamp AS time, q.source, t.topicname, t.topictext, q.topic, 'oldqueue' AS queue\r\n\t\t\t\t\t\t\t\tFROM nuke_queue AS q\r\n\t\t\t\t\t\t\t\tLEFT JOIN nuke_topics AS t ON q.topic = t.topicid\r\n\t\t\t\t\t\t\t\tLEFT JOIN nuke_users AS u ON q.uid = u.user_id\r\n\t\t\t\t\t\t\t\tWHERE q.qid = ?"; } else { $query = "SELECT s.*, t.topicname, t.topicimage, t.topictext, t.topicid \r\n\t\t\t\t\t\t\t\tFROM nuke_stories AS s \r\n\t\t\t\t\t\t\t\tLEFT JOIN nuke_topics AS t ON s.topic = t.topicid\r\n\t\t\t\t\t\t\t\tWHERE s.sid = ?"; } $return = $this->db_readonly->fetchRow($query, $this->id); } /* } */ if (isset($return) && is_array($return) && !empty($return)) { $this->title = $return['title']; $this->blurb = $return['hometext']; $this->body = $return['bodytext']; $this->date = new DateTime($return['time']); $this->hits = isset($return['weeklycounter']) ? intval($return['weeklycounter']) : 0; $this->Topic = new Topic($return['topic']); $this->user_id = isset($return['user_id']) ? intval($return['user_id']) : 0; $this->staff_user_id = isset($return['staff_id']) ? intval($return['staff_id']) : 0; $this->topic_id = isset($return['ForumThreadID']) ? intval($return['ForumThreadID']) : 0; $this->source = $return['source']; $this->approved = isset($return['approved']) ? (bool) $return['approved'] : false; $this->sent_to_fb = isset($return['sent_to_fb']) ? (bool) $return['sent_to_fb'] : false; $this->featured_image = isset($return['featured_image']) ? $return['featured_image'] : false; if (isset($return['geo_lat']) && !empty($return['geo_lat']) && isset($return['geo_lon']) && !empty($return['geo_lon'])) { $this->lat = $return['geo_lat']; $this->lon = $return['geo_lon']; } if (empty($return['slug'])) { $return['slug'] = $this->createSlug(); } $this->slug = $return['slug']; $this->url = new Url($this->makePermaLink($this->slug)); $this->blurb_clean = format_post($this->blurb, false, false, true, true, true); $this->body_clean = format_post($this->body, false, false, true, true, true); $this->setAuthor(new User($this->user_id)); $this->username = $this->Author->username; $this->setStaff(new User($this->staff_user_id)); $this->staff_username = $this->Staff->username; // Rest of this shit is for backwards compatibility $whitespace_find = array("<p> </p>", "<p></p>", "<p> </p>"); $whitespace_replace = array("", "", ""); #$return['hometext'] = format_post(str_replace($whitespace_find, $whitespace_replace, $return['hometext'])); #$return['bodytext'] = format_post(str_replace($whitespace_find, $whitespace_replace, $return['bodytext'])); #$return['hometext'] = convert_to_utf8($return['hometext']); #$return['bodytext'] = convert_to_utf8($return['bodytext']); #$return['hometext'] = wpautop($return['hometext']); #$return['bodytext'] = process_multimedia(wpautop($return['bodytext'])); try { $this->fwlink = new \Railpage\fwlink($this->url); if (empty($this->fwlink->url)) { $this->fwlink->url = $this->url; $this->fwlink->title = $this->title; $this->fwlink->commit(); } } catch (Exception $e) { global $Error; $Error->save($e); } } else { #throw new Exception($this->db->error."\n\n".$query); throw new Exception(sprintf("Cannot find news article #%d", $this->id)); return false; } return $return; }
public function commit() { return $this->connection->commit(); }
/** * 事务提交 */ public function commit() { $this->_getChoiceDbConnect(true); $this->_db->commit(); }
/** * Commit transaction. * * @return bool */ public function commit() { return $this->dbHandle->commit(); }
/** * * 提交事务 * * @author liu21st <*****@*****.**> * @lastmodify 2013-01-21 14:53:15 by mrmsl * * @return object this */ public function commit() { $this->_db->commit(); return $this; }
public function commit() { echo "Committing transaction\n"; return $this->db->commit(); }
/** * Procedimiento que almacena el item de menú como parte del historial de * navegación del usuario indicado por $uid. El historial del usuario debe * cumplir las siguientes propiedades: * - El historial es una lista con un máximo número de items (5), parecido, pero * no idéntico, a una cola FIFO. * - Los items están ordenados por su ID de inserción. El item más reciente es * el item de mayor número de inserción. * - Repetidas llamadas sucesivas a esta función con el mismo valor de $uid y * $menu deben dejar la lista inalterada, asumiendo que no hayan otras * ventanas de navegación abierta. * - Si la lista tiene su número máximo de items y se agrega un nuevo item que * no estaba previamente presente en la lista, el item más antiguo se olvida. * - Si el item resulta idéntico en menú a uno que ya existe, debe de quitarse * de su posición actual y colocarse en la parte superior de la lista. El * número de items debe quedar inalterado. * * @param object $pdbACL Objeto paloDB conectado a las tablas de ACL. * @param object $pACL Objeto paloACL para consultar IDs de menú. * @param integer $uid ID de usuario para el historial * @param string $menu Item de menú a insertar en el historial * * @return bool VERDADERO si se inserta el item, FALSO en error. */ function putMenuAsHistory($pdbACL, $pACL, $uid, $menu) { global $arrConf; $pDB = new paloDB($arrConf['elastix_dsn']['settings']); if (empty($pDB->errMsg)) { $uelastix = get_key_settings($pDB, 'uelastix'); if ((int) $uelastix != 0) { return TRUE; } } $id_resource = $pACL->getResourceId($menu); if (is_null($id_resource)) { return FALSE; } // Leer historial actual. El item 0 es el más reciente $sqlselect = <<<SQL_LEER_HISTORIAL SELECT aus.id AS id, ar.id AS id_menu FROM acl_user_shortcut aus, acl_resource ar WHERE id_user = ? AND type = 'history' AND ar.id = aus.id_resource ORDER BY aus.id DESC SQL_LEER_HISTORIAL; $historial = $pdbACL->fetchTable($sqlselect, TRUE, array($uid)); if (!is_array($historial)) { return FALSE; } if (count($historial) > 0 && $historial[0]['id_menu'] == $id_resource) { return TRUE; } // Idempotencia for ($i = 0; $i < count($historial); $i++) { $historial[$i]['modified'] = FALSE; } // Procesar la lista según las reglas requeridas $shiftindex = NULL; for ($i = 0; $i < count($historial); $i++) { if ($historial[$i]['id_menu'] == $id_resource) { $shiftindex = $i; break; } } if (is_null($shiftindex) && count($historial) >= 5) { $shiftindex = count($historial); } // Insertar nuevo item al inicio, corriendo los items si es necesario if (!is_null($shiftindex)) { for ($i = $shiftindex; $i > 0; $i--) { if ($i < count($historial)) { $historial[$i]['id_menu'] = $historial[$i - 1]['id_menu']; $historial[$i]['modified'] = TRUE; } } $historial[0]['id_menu'] = $id_resource; $historial[0]['modified'] = TRUE; } else { array_unshift($historial, array('id' => NULL, 'id_menu' => $id_resource, 'modified' => TRUE)); } // Guardar en la DB todas las modificaciones $pdbACL->beginTransaction(); foreach ($historial as $item) { if ($item['modified']) { if (is_null($item['id'])) { $sqlupdate = 'INSERT INTO acl_user_shortcut (id_resource, id_user, type) VALUES (?, ?, ?)'; $paramsql = array($item['id_menu'], $uid, 'history'); } else { $sqlupdate = 'UPDATE acl_user_shortcut SET id_resource = ? WHERE id_user = ? AND type = ? AND id = ?'; $paramsql = array($item['id_menu'], $uid, 'history', $item['id']); } if (!$pdbACL->genQuery($sqlupdate, $paramsql)) { $pdbACL->rollBack(); return FALSE; } } } $pdbACL->commit(); return TRUE; }