/**
* Array<string> list of column names
+ * @var array
*/
private $columns;
*/
public static function dao(CRM_Core_DAO $dao) {
$table = CRM_Core_DAO::getLocaleTableName($dao->getTableName());
- $row = array();
+ $row = [];
foreach ((array) $dao as $key => $value) {
if ($value === 'null') {
- $value = NULL; // Blerg!!!
+ // Blerg!!!
+ $value = NULL;
}
// Skip '_foobar' and '{\u00}*_options' and 'N'.
- if (preg_match('/[a-zA-Z]/', $key{0}) && $key !== 'N') {
+ if (preg_match('/[a-zA-Z]/', $key[0]) && $key !== 'N') {
$row[$key] = $value;
}
}
*/
public function __construct($table) {
$this->table = $table;
- $this->rows = array();
+ $this->rows = [];
}
/**
sort($columns);
$this->columns = $columns;
}
- elseif (array_diff($this->columns, $columns) !== array()) {
+ elseif (array_diff($this->columns, $columns) !== []) {
throw new CRM_Core_Exception("Inconsistent column names");
}
- $escapedRow = array();
+ $escapedRow = [];
foreach ($this->columns as $column) {
$escapedRow[$column] = $this->escapeString($row[$column]);
}
/**
* Escape string.
*
- * @param string|NULL $value
+ * @param string|null $value
*
* @return string
* SQL expression, e.g. "it\'s great" (with-quotes) or NULL (without-quotes)