function setup() { if ($this->isType('mysql')) { if ($this->getCreateTarget() == true) { $this->connection =& NewADOConnection($this->dbConfig->getDBType()); $ok = $this->connection->NConnect($this->dbConfig->getHostName(), $this->dbConfig->getRootUserName(), $this->dbConfig->getRootPassword()); if (!$ok) { throw new DatabaseBackupException(DatabaseBackupErrorCode::$DB_CONNECT_ERROR, DatabaseBackup::$langString['DestConnectFailed']); } // Drop database if already exists $sql = "drop database IF EXISTS " . $this->dbConfig->getDatabaseName(); $result = $this->connection->Execute($sql); $this->checkError($result, $sql); $sql = 'create database ' . $this->dbConfig->getDatabaseName(); if ($this->supportUTF8 == true) { $sql .= " default character set utf8 default collate utf8_general_ci"; } $result = $this->connection->Execute($sql); $this->checkError($result, $sql); $this->connection->Close(); } $this->connection =& NewADOConnection($this->dbConfig->getDBType()); $ok = $this->connection->NConnect($this->dbConfig->getHostName(), $this->dbConfig->getUserName(), $this->dbConfig->getPassword(), $this->dbConfig->getDatabaseName()); if (!$ok) { throw new DatabaseBackupException(DatabaseBackupErrorCode::$DB_CONNECT_ERROR, DatabaseBackup::$langString['DestConnectFailed']); } $result = $this->connection->_Execute("SET interactive_timeout=28800", false); $result = $this->connection->_Execute("SET wait_timeout=28800", false); $result = $this->connection->_Execute("SET net_write_timeout=900", false); } }
/** * Remove right * * @param array $params * @return void */ public function removeRight(array $params) { $rightId = (int) $params['right_id']; // get permission $sql = 'SELECT right_define_name FROM ' . self::RIGHTS . "\n WHERE right_id = {$rightId}"; $permission = $this->db->GetOne($sql); // remove acl rules try { list($resource, ) = PermissionToAcl::translate($permission); } catch (\InvalidArgumentException $e) { return; } $sql = 'DELETE FROM ' . self::RULES . "\n WHERE resource = '{$resource}'"; $this->db->Execute($sql); // remove right $sql = 'DELETE FROM ' . self::RIGHTS . "\n WHERE right_id = {$rightId}"; $this->db->Execute($sql); }
function Execute($sql, $inputarr = false) { return ADOConnection::Execute($sql, $inputarr); }
function Execute($sql, $inputarr = false) { if ($this->is_utf) { $sql = preg_replace('/(\'.*\')/', 'N$1', $sql); } return parent::Execute($sql, $inputarr); }
public function autoIncrement($sec) { $res = $this->db->Execute('SELECT :sec nextval FROM dual commit', array("sec" => $sec)); return $res->_array[0]['NEXTVAL']; }
/** * Create DB connection */ protected function connect() { /** @var $this->connection \ADOConnection */ $this->connection =& NewADOConnection($this->driver); $host = $this->host; if ($this->port) { $host .= ':' . $this->port; } // connect if ($this->db) { $this->connection->Connect($host, $this->user, $this->password, $this->db); } else { $this->connection->Connect($host, $this->user, $this->password); } // check connection if (!$this->connection->IsConnected()) { $errMsg = $this->connection->ErrorMsg(); $this->utilityFuncs->throwException('db_connection_failed', $errMsg); } // execute initial statement if ($this->setDBinit) { $this->utilityFuncs->debugMessage('sql_request', [$this->setDBinit]); $this->connection->Execute($this->setDBinit); // error occured? if ($this->connection->ErrorNo() != 0) { $errMsg = $this->connection->ErrorMsg(); $this->utilityFuncs->debugMessage('sql_request_error', [$errMsg], 3); } } }
function CreateLogInfo($good_id, $is_auto = 1, $myinfo = '') { $query = "insert into loginfo(created, good_id, source, loginfo, ip)\n values(now(), " . intval($good_id) . ", " . intval($is_auto) . ", '" . $this->ProtectString($myinfo) . "', '" . $_SERVER['REMOTE_ADDR'] . "')\n "; $this->_main_conn->Execute($query); }
/** * Get the string to select, insert, update or compare special fields * without a leading or trailing decimal point * * In case of comparison the chaining operator will be added in front of * every special field * @param \ADOConnection $dbCon The database connection * @param array $data The data to insert or * update the entry * @param string $comparator Relational operator * i.e. LIKE * @param string $compareValue Value to use with relational * operator * @param string $chainingOperator Operator to chain * comparisons i.e. OR * @return string */ protected function getSpecialFieldsQueryPart($dbCon, $data = null, $comparator = '', $compareValue = '', $chainingOperator = ',') { $specialFields = array(); // get amount of special fields $specialFieldCount = count($this->specialFields); if (empty($specialFieldCount)) { $specialFieldCount = $dbCon->Execute("SELECT COUNT(*) AS `count` FROM `" . DBPREFIX . "module_market_spez_fields` WHERE `lang_id` = 1"); $specialFieldCount = $specialFieldCount->fields['count']; } for ($i = 1; $i <= $specialFieldCount; ++$i) { $value = ''; // Data needs to be updated or inserted if (!empty($data)) { $value = '=\'' . contrexx_input2db($data['spez_' . $i]) . '\''; } // Special fields are used in WHERE or similar comparison statements if (empty($data) && !empty($comparator) && !empty($compareValue)) { $value = ' ' . $comparator . ' ' . $compareValue; } $specialFields[] = 'spez_field_' . $i . $value; } $specialFields = join(' ' . $chainingOperator . ' ', $specialFields); return $specialFields; }
/** * Set the Oracle password for a user, if they have an Oracle account. Since we cannot * use variable binding, validate the username and password before we pass them to * the script * * @param $database \b ADOConnection an adodb connection * @param $username \b string username * @param $password \b string the new password */ public static function setOraclePassword(ADOConnection $database, $username, $password) { $username = strtoupper($username); // do not proceed if user does not have an account in this database if (!$database->GetOne("SELECT 1 FROM dba_users WHERE username = :u", array('u' => $username))) { return false; } if (!self::validateOraclePassword($password)) { throw new Exception('Invalid password'); } if (!self::validateOracleUsername($username)) { throw new Exception('Invalid username'); } $password = str_replace('"', '\\"', $password); $database->Execute("ALTER USER {$username} IDENTIFIED BY \"{$password}\""); if ($database->ErrorNo() > 0) { throw new Exception("Database error:" . $database->ErrorMsg()); } return true; }