Elgg\Database\EntityTable::insertRow PHP Method

insertRow() public method

Adds a new row to the entity table
public insertRow ( stdClas\stdClass $row, array $attributes = [] ) : integer | false
$row stdClas\stdClass Entity base information
$attributes array All primary and secondary table attributes Used by database mock services to allow mocking entities that were instantiated using new keyword and calling ElggEntity::save()
return integer | false
    public function insertRow(stdClass $row, array $attributes = [])
    {
        $sql = "INSERT INTO {$this->db->prefix}entities\n\t\t\t(type, subtype, owner_guid, container_guid,\n\t\t\t\taccess_id, time_created, time_updated, last_action)\n\t\t\tVALUES\n\t\t\t(:type, :subtype_id, :owner_guid, :container_guid,\n\t\t\t\t:access_id, :time_created, :time_updated, :last_action)";
        return $this->db->insertData($sql, [':type' => $row->type, ':subtype_id' => $row->subtype_id, ':owner_guid' => $row->owner_guid, ':container_guid' => $row->container_guid, ':access_id' => $row->access_id, ':time_created' => $row->time_created, ':time_updated' => $row->time_updated, ':last_action' => $row->last_action]);
    }

Usage Example

コード例 #1
0
ファイル: EntityTable.php プロジェクト: elgg/elgg
 /**
  * {@inheritdoc}
  */
 public function insertRow(stdClass $row, array $attributes = [])
 {
     $subtype = isset($row->subtype) ? $row->subtype : null;
     $this->setup(null, $row->type, $subtype, array_merge($attributes, (array) $row));
     return parent::insertRow($row);
 }