<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.4 |
+ | CiviCRM version 4.5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2013 |
+ | Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* Our base DAO class. All DAO classes should inherit from this class.
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2013
+ * @copyright CiviCRM LLC (c) 2004-2014
* $Id$
*
*/
}
if ($trapException) {
- CRM_Core_Error::ignoreException();
+ $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
}
$result = $dao->query($queryStr, $i18nRewrite);
- if ($trapException) {
- CRM_Core_Error::setCallback();
- }
-
if (is_a($result, 'DB_Error')) {
return $result;
}
return self::escapeString($string);
}
- //Creates a test object, including any required objects it needs via recursion
- //createOnly: only create in database, do not store or return the objects (useful for perf testing)
- //ONLY USE FOR TESTING
+ /**
+ * Creates a test object, including any required objects it needs via recursion
+ *createOnly: only create in database, do not store or return the objects (useful for perf testing)
+ *ONLY USE FOR TESTING
+ */
static function createTestObject(
$daoName,
$params = array(),
else return $objects;
}
- //deletes the this object plus any dependent objects that are associated with it
- //ONLY USE FOR TESTING
-
+ /**
+ * deletes the this object plus any dependent objects that are associated with it
+ * ONLY USE FOR TESTING
+ */
static function deleteTestObjects($daoName, $params = array(
)) {
//this is a test function also backtrace is set for the test suite it sometimes unsets itself
// test for create view and trigger permissions and if allowed, add the option to go multilingual
// and logging
// I'm not sure why we use the getStaticProperty for an error, rather than checking for DB_Error
- CRM_Core_Error::ignoreException();
+ $errorScope = CRM_Core_TemporaryErrorScope::ignoreException();
$dao = new CRM_Core_DAO();
if ($view) {
$dao->query('CREATE OR REPLACE VIEW civicrm_domain_view AS SELECT * FROM civicrm_domain');
if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
- CRM_Core_Error::setCallback();
return FALSE;
}
}
if ($trigger) {
$result = $dao->query('CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EACH ROW BEGIN END');
if (PEAR::getStaticProperty('DB_DataObject', 'lastError') || is_a($result, 'DB_Error')) {
- CRM_Core_Error::setCallback();
if ($view) {
$dao->query('DROP VIEW IF EXISTS civicrm_domain_view');
}
$dao->query('DROP TRIGGER IF EXISTS civicrm_domain_trigger');
if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
- CRM_Core_Error::setCallback();
if ($view) {
$dao->query('DROP VIEW IF EXISTS civicrm_domain_view');
}
if ($view) {
$dao->query('DROP VIEW IF EXISTS civicrm_domain_view');
if (PEAR::getStaticProperty('DB_DataObject', 'lastError')) {
- CRM_Core_Error::setCallback();
return FALSE;
}
}
- CRM_Core_Error::setCallback();
return TRUE;
}
public static function createSQLFilter($fieldName, $filter, $type, $alias = NULL, $returnSanitisedArray = FALSE) {
// http://issues.civicrm.org/jira/browse/CRM-9150 - stick with 'simple' operators for now
// support for other syntaxes is discussed in ticket but being put off for now
- $acceptedSQLOperators = array('=', '<=', '>=', '>', '<', 'LIKE', "<>", "!=", "NOT LIKE", 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN');
foreach ($filter as $operator => $criteria) {
- if (in_array($operator, $acceptedSQLOperators)) {
+ if (in_array($operator, self::acceptedSQLOperators())) {
switch ($operator) {
// unary operators
case 'IS NULL':
}
}
+ /**
+ * @see http://issues.civicrm.org/jira/browse/CRM-9150
+ * support for other syntaxes is discussed in ticket but being put off for now
+ * @return array
+ */
+ public static function acceptedSQLOperators() {
+ return array('=', '<=', '>=', '>', '<', 'LIKE', "<>", "!=", "NOT LIKE", 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN');
+ }
+
/**
* SQL has a limit of 64 characters on various names:
* table name, trigger name, column name ...