Elgg  Version 6.1
20211224075815_set_comments_level_one.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types=1);
3 
5 
6 final class SetCommentsLevelOne extends AbstractMigration {
10  public function up() {
11  $prefix = $this->getAdapter()->getOption('table_prefix');
12 
13  $sub_query = "SELECT entity_guid FROM {$prefix}metadata WHERE name = 'level'";
14  $time_created = time();
15 
16  $this->execute("
17  INSERT INTO {$prefix}metadata (entity_guid, name, value, value_type, time_created)
18  SELECT
19  e.guid AS entity_guid,
20  'level' AS name,
21  1 AS value,
22  'integer' AS value_type,
23  {$time_created} AS time_created
24  FROM {$prefix}entities e
25  WHERE
26  e.guid NOT IN ({$sub_query}) AND
27  e.type = 'object' AND
28  e.subtype = 'comment'
29  ");
30  }
31 }
if(!$user instanceof\ElggUser) $time_created
Definition: online.php:13
up()
Add level = 1 metadata to comments.