+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2018 |
+ | Copyright CiviCRM LLC (c) 2004-2019 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
* All DAO classes should inherit from this class.
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2018
+ * @copyright CiviCRM LLC (c) 2004-2019
*/
if (!defined('DB_DSN_MODE')) {
if (!$serializeArrays && is_array($pValue) && !empty($value['serialize'])) {
Civi::log()->warning(ts('use copyParams to serialize arrays (' . __CLASS__ . '.' . $name . ')'), ['civi.tag' => 'deprecated']);
}
+ $maxLength = CRM_Utils_Array::value('maxlength', $value);
+ if (!is_array($pValue) && $maxLength && mb_strlen($pValue) > $maxLength
+ && empty($value['pseudoconstant'])
+ ) {
+ Civi::log()->warning(ts('A string for field $dbName has been truncated. The original string was %1', [CRM_Utils_Type::escape($pValue, 'String')]));
+ // The string is too long - what to do what to do? Well losing data is generally bad so lets' truncate
+ $pValue = CRM_Utils_String::ellipsify($pValue, $maxLength);
+ }
$this->$dbName = $pValue;
$allNull = FALSE;
}
/**
* Check if there is a given column in a specific table.
*
+ * @deprecated
+ * @see CRM_Core_BAO_SchemaHandler::checkIfFieldExists
+ *
* @param string $tableName
* @param string $columnName
* @param bool $i18nRewrite
* true if exists, else false
*/
public static function checkFieldExists($tableName, $columnName, $i18nRewrite = TRUE) {
- $query = "
-SHOW COLUMNS
-FROM $tableName
-LIKE %1
-";
- $params = array(1 => array($columnName, 'String'));
- $dao = CRM_Core_DAO::executeQuery($query, $params, TRUE, NULL, FALSE, $i18nRewrite);
- $result = $dao->fetch() ? TRUE : FALSE;
- $dao->free();
- return $result;
+ return CRM_Core_BAO_SchemaHandler::checkIfFieldExists($tableName, $columnName, $i18nRewrite);
}
/**
while ($dao->fetch()) {
$values[] = $dao->TABLE_NAME;
}
- $dao->free();
return $values;
}
AND TABLE_NAME LIKE 'civicrm_%'
AND TABLE_NAME NOT LIKE 'civicrm_import_job_%'
AND TABLE_NAME NOT LIKE '%_temp%'
+ AND TABLE_NAME NOT LIKE 'civicrm_tmp_%'
");
}
CRM_Core_Error::fatal();
}
- $dao->free();
$show[$tableName] = $dao->Create_Table;
}
CRM_Core_Error::fatal();
}
- $dao->free();
$show[$tableName] = $dao->Create_Table;
}
CRM_Core_Error::fatal();
}
- $dao->free();
$show[$tableName] = $dao->Create_Table;
}
$constraint = "`FK_{$tableName}_{$columnName}`";
$query = "SELECT * FROM $tableName WHERE $columnName != '$columnValue'";
$dao = CRM_Core_DAO::executeQuery($query);
$result = $dao->fetch() ? FALSE : TRUE;
- $dao->free();
return $result;
}
$query = "SELECT * FROM $tableName WHERE $columnName IS NOT NULL";
$dao = CRM_Core_DAO::executeQuery($query);
$result = $dao->fetch() ? FALSE : TRUE;
- $dao->free();
return $result;
}
$dao = CRM_Core_DAO::executeQuery($query, $params);
$result = $dao->fetch() ? TRUE : FALSE;
- $dao->free();
return $result;
}
) {
// we typically do this for insert/update/delete statements OR if explicitly asked to
// free the dao
- $dao->free();
}
return $dao;
}
}
}
$newObject->save();
+ CRM_Utils_Hook::post('create', CRM_Core_DAO_AllCoreTables::getBriefName($daoName), $newObject->id, $newObject);
}
+
return $newObject;
}