/** * @inheritdoc */ public function checkError($msg = '', $dieOnError = false) { $result = parent::checkError($msg, $dieOnError); if ($result) { $this->disconnect(); } return $result; }
public function query($sql, $dieOnError = false, $msg = '', $suppress = false, $keepResult = false) { global $app_strings; if (is_array($sql)) { return $this->queryArray($sql, $dieOnError, $msg, $suppress); } $sql = $this->_appendN($sql); return parent::query($sql, $dieOnError, $msg, $suppress, $keepResult); }
/** * @see DBManager::query() */ public function query($sql, $dieOnError = false, $msg = '', $suppress = false) { // Flag if there are odd number of single quotes if (substr_count($sql, "'") & 1) { $GLOBALS['log']->error("SQL statement[" . $sql . "] has odd number of single quotes."); } $sql = $this->appendN($sql); parent::countQuery($sql); $GLOBALS['log']->info('Query:' . $sql); $this->checkConnection(); $this->query_time = microtime(true); if ($suppress) { } else { $result = @mssql_query($sql, $this->database); } if (!$result) { // awu Bug 10657: ignoring mssql error message 'Changed database context to' - an intermittent // and difficult to reproduce error. The message is only a warning, and does // not affect the functionality of the query $sqlmsg = mssql_get_last_message(); $sqlpos = strpos($sqlmsg, 'Changed database context to'); if ($dieOnError) { if ($sqlpos !== false) { // if sqlmsg has 'Changed database context to', just log it $GLOBALS['log']->debug(mssql_get_last_message() . ": " . $sql); } else { sugar_die('SQL Error : ' . mssql_get_last_message()); } } else { echo 'SQL Error : ' . mssql_get_last_message(); } $GLOBALS['log']->fatal(mssql_get_last_message() . ": " . $sql); } $this->lastmysqlrow = -1; $this->query_time = microtime(true) - $this->query_time; $GLOBALS['log']->info('Query Execution Time:' . $this->query_time); $this->checkError($msg . ' Query Failed:' . $sql . '::', $dieOnError); return $result; }
/** * Override method to add support for detecting and dropping fulltext indices. * * @see DBManager::changeColumnSQL() * @see MssqlHelper::changeColumnSQL() */ protected function changeColumnSQL($tablename, $fieldDefs, $action, $ignoreRequired = false) { $sql = ''; if ($action == 'drop' && $this->doesTableHaveAFulltextIndexDefined($tablename)) { $sql .= "DROP FULLTEXT INDEX ON {$tablename}"; } $sql .= parent::changeColumnSQL($tablename, $fieldDefs, $action, $ignoreRequired); return $sql; }
/** * Test checks order by string in different queries * * @group 54990 * @dataProvider getQueriesForReturnOrderBy */ public function testReturnOrderBy($query, $start, $count, $expected) { $actual = $this->_db->limitQuery($query, $start, $count, false, '', false); $this->assertContains($expected, $actual, 'Order By is incorrect'); }
/** * Compares two vardefs. Overriding 39098 due to bug: 39098 . IN 6.0 we changed the id columns to dbType = 'id' * for example emails_beans. In 554 the field email_id was nvarchar but in 6.0 since it id dbType = 'id' we would want to alter * it to varchar. This code will prevent it. * * @param array $fielddef1 * @param array $fielddef2 * @return bool true if they match, false if they don't */ public function compareVarDefs($fielddef1, $fielddef2) { if (isset($fielddef2['dbType']) && $fielddef2['dbType'] == 'id' || preg_match('/(_id$|^id$)/', $fielddef2['name'])) { if (isset($fielddef1['type']) && isset($fielddef2['type'])) { $fielddef2['type'] = $fielddef1['type']; } } return parent::compareVarDefs($fielddef1, $fielddef2); }
public function __construct() { parent::__construct(); $this->_resultsCache = new ArrayObject(); }
function arrayQuote(&$array, $isLike = true) { for ($i = 0; $i < count($array); $i++) { $array[$i] = MssqlManager::quote($array[$i]); } }