71 if (!in_array(
$name, $this->tag_names)) {
72 $this->tag_names[] =
$name;
88 unset($this->tag_names[
$index]);
132 $singulars = [
'tag_name'];
133 $options = LegacyQueryOptionsAdapter::normalizePluralOptions(
$options, $singulars);
148 return "{$main_alias}.value AS tag";
151 return "COUNT({$main_alias}.id) AS total";
168 return "{$main_alias}.value";
174 $having[] =
function(
QueryBuilder $qb, $main_alias) use ($threshold) {
185 $options[
'callback'] =
function($row) {
188 $result->total = (int) $row->total;
206 public function get(
$id) {
212 $qb->addClause($where);
214 $row = $this->db->getDataRow($qb);
242 $deleted = $this->db->deleteData($qb);
245 $this->metadata_cache->clear(
$metadata->entity_guid);
264 if (!isset($metadata->value) || !isset($metadata->entity_guid)) {
265 elgg_log(
"Metadata must have a value and entity guid",
'ERROR');
269 if (!is_scalar($metadata->value)) {
270 elgg_log(
"To set multiple metadata values use ElggEntity::setMetadata",
'ERROR');
275 if ($this->
update($metadata)) {
276 return $metadata->id;
280 if (strlen($metadata->value) > self::MYSQL_TEXT_BYTE_LIMIT) {
281 elgg_log(
"Metadata '{$metadata->name}' is above the MySQL TEXT size limit and may be truncated.",
'WARNING');
284 if (!$allow_multiple) {
288 throw new \LogicException(
" 289 Multiple '{$metadata->name}' metadata values exist for entity [guid: {$metadata->entity_guid}]. 290 Use ElggEntity::setMetadata() 297 if ($this->
update($metadata)) {
298 return $metadata->id;
303 if (!$this->events->triggerBefore(
'create',
'metadata', $metadata)) {
314 'value_type' => $qb->param($metadata->value_type, ELGG_VALUE_STRING),
318 $id = $this->db->insertData($qb);
324 $metadata->id = (int)
$id;
327 if ($this->events->trigger(
'create',
'metadata', $metadata)) {
328 $this->metadata_cache->clear($metadata->entity_guid);
330 $this->events->triggerAfter(
'create',
'metadata', $metadata);
350 if (!$this->events->triggerBefore(
'update',
'metadata', $metadata)) {
354 if (strlen($metadata->value) > self::MYSQL_TEXT_BYTE_LIMIT) {
355 elgg_log(
"Metadata '{$metadata->name}' is above the MySQL TEXT size limit and may be truncated.",
'WARNING');
361 ->
set(
'value_type', $qb->param($metadata->value_type, ELGG_VALUE_STRING))
364 $result = $this->db->updateData($qb);
370 $this->metadata_cache->clear($metadata->entity_guid);
372 $this->events->trigger(
'update',
'metadata', $metadata);
373 $this->events->triggerAfter(
'update',
'metadata', $metadata);
391 $options[
'metastring_type'] =
'metadata';
413 ->orderBy(
'entity_guid',
'asc')
414 ->orderBy(
'time_created',
'asc')
415 ->orderBy(
'id',
'asc');
417 return $qb->execute()->fetchAll();
441 $this->metadata_cache->invalidateByOptions($options);
443 $options[
'batch'] =
true;
444 $options[
'batch_size'] = 50;
445 $options[
'batch_inc_offset'] =
false;
462 return $success ==
$count;
482 $callback =
function (\stdClass $row) {
483 return (
int) $row->id;
486 $ids = $this->db->getData($qb, $callback);
493 if (is_array($ids) && count($ids) === 1) {
494 return array_shift($ids);
if(!$user||!$user->canDelete()) $name
_elgg_is_valid_options_for_batch_operation($options, $type)
Checks if there are some constraints on the options array for potentially dangerous operations...
static find(array $options=[])
Build and execute a new query from an array of legacy options.
static table($table, $alias=null)
{}
const ELGG_VALUE_INTEGER
Value types.
Database abstraction query builder.
getCurrentTime($modifier= '')
Get the (cloned) time.
static intoTable($table)
{}
$id
River item delete action.
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
compare($x, $comparison, $y=null, $type=null, $case_sensitive=null)
Build value comparison clause.
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Extends QueryBuilder with ORDER BY clauses.
static fromTable($table, $alias=null)
{}
$guids
Activates all specified installed and inactive plugins.
_elgg_services()
Get the global service provider.
trait TimeUsing
Adds methods for setting the current time (for testing)
static fromTable($table, $alias=null)
{}