Civi::$statics[__CLASS__]['init'] = 1;
$options = &PEAR::getStaticProperty('DB_DataObject', 'options');
$options['database'] = $dsn;
+ $options['quote_identifiers'] = TRUE;
if (defined('CIVICRM_DAO_DEBUG')) {
self::DebugLevel(CIVICRM_DAO_DEBUG);
}
* @param array $fieldDef
* @param int $counter
* The globally-unique ID of the test object.
+ *
+ * @throws \CRM_Core_Exception
*/
protected function assignTestValue($fieldName, &$fieldDef, $counter) {
$dbName = $fieldDef['name'];
break;
case CRM_Utils_Type::T_TIME:
- CRM_Core_Error::fatal("T_TIME shouldn't be used.");
- //$object->$dbName='000000';
- //break;
+ throw new CRM_Core_Exception('T_TIME shouldn\'t be used.');
+
case CRM_Utils_Type::T_CCNUM:
$this->$dbName = '4111 1111 1111 1111';
break;
*
* @return bool
* true if constraint exists, false otherwise
+ *
+ * @throws \CRM_Core_Exception
*/
public static function checkConstraintExists($tableName, $constraint) {
static $show = [];
$dao = CRM_Core_DAO::executeQuery($query, [], TRUE, NULL, FALSE, FALSE);
if (!$dao->fetch()) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('query failed');
}
$show[$tableName] = $dao->Create_Table;
*
* @param array $tables
*
- * @throws Exception
+ * @throws CRM_Core_Exception
*
* @return bool
* true if CONSTRAINT keyword exists, false otherwise
$dao = CRM_Core_DAO::executeQuery($query, [], TRUE, NULL, FALSE, FALSE);
if (!$dao->fetch()) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Show create table failed.');
}
$show[$tableName] = $dao->Create_Table;
*
* @return bool
* true if in format, false otherwise
+ *
+ * @throws \CRM_Core_Exception
*/
public static function checkFKConstraintInFormat($tableName, $columnName) {
static $show = [];
$dao = CRM_Core_DAO::executeQuery($query);
if (!$dao->fetch()) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('query failed');
}
$show[$tableName] = $dao->Create_Table;
*
* @return array
*/
- public function fetchAll() {
+ public function fetchAll($k = FALSE, $v = FALSE, $method = FALSE) {
$result = [];
while ($this->fetch()) {
$result[] = $this->toArray();
*
* @return string|null
* Value of $returnColumn in the retrieved record
+ *
+ * @throws \CRM_Core_Exception
*/
public static function getFieldValue($daoName, $searchValue, $returnColumn = 'name', $searchColumn = 'id', $force = FALSE) {
if (
// adding this here since developers forget to check for an id
// or for the 'null' (which is a bad DAO kludge)
// and hence we get the first value in the db
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('getFieldValue failed');
}
self::$_dbColumnValueCache = self::$_dbColumnValueCache ?? [];
* @see CRM_Utils_SQL_TempTable
*/
public static function createTempTableName($prefix = 'civicrm', $addRandomString = TRUE, $string = NULL) {
+ CRM_Core_Error::deprecatedFunctionWarning('Use CRM_Utils_SQL_TempTable interface to create temporary tables');
$tableName = $prefix . "_temp";
if ($addRandomString) {
* @param array $fields
*/
public static function appendPseudoConstantsToFields(&$fields) {
- foreach ($fields as $field) {
+ foreach ($fields as $fieldUniqueName => $field) {
if (!empty($field['pseudoconstant'])) {
$pseudoConstant = $field['pseudoconstant'];
if (!empty($pseudoConstant['optionGroupName'])) {
'title' => CRM_Core_BAO_OptionGroup::getTitleByName($pseudoConstant['optionGroupName']),
'name' => $pseudoConstant['optionGroupName'],
'data_type' => CRM_Utils_Type::T_STRING,
- 'is_pseudofield_for' => $field['name'],
+ 'is_pseudofield_for' => $fieldUniqueName,
];
}
// We restrict to id + name + FK as we are extending this a bit, but cautiously.
return strlen($value) ? json_decode($value, TRUE) : [];
case self::SERIALIZE_PHP:
- return strlen($value) ? unserialize($value, ['allowed_classes' => FALSE]) : [];
+ return strlen($value) ? CRM_Utils_String::unserialize($value) : [];
case self::SERIALIZE_COMMA:
return explode(',', trim(str_replace(', ', '', $value)));