HEX
Server: Apache
System: Linux server1.ariadata.co 4.18.0-553.120.1.el8_10.x86_64 #1 SMP Mon Apr 20 18:04:27 EDT 2026 x86_64
User: nepi (1051)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,show_source,popen,proc_open
Upload Files
File: /home/nepi/public_html/src/core/Directus/Database/Query/Relations/OneToManyRelation.php
<?php

namespace Directus\Database\Query\Relations;

use Directus\Database\Query\Builder;
use Zend\Db\Sql\Predicate\Expression;

class OneToManyRelation extends Builder
{
    protected $parentBuilder;
    protected $column;
    protected $table;
    protected $columnRight;
    protected $relatedTable;

    public function __construct(Builder $builder, $column, $table, $columnRight, $relatedTable)
    {
        parent::__construct($builder->getConnection());

        $this->parentBuilder = $builder;
        $this->column = $column;
        $this->table = $table;
        $this->columnRight = $columnRight;
        $this->relatedTable = $relatedTable;

        $this->columns([$this->column]);
        $this->from($relatedTable);
        $on = sprintf('%s.%s = %s.%s', $this->relatedTable, $this->column, $this->table, $this->columnRight);
        $this->join($this->table, $on, [$this->columnRight], 'right');
    }

    public function all(array $values)
    {
        $this->columns([]);
        $this->whereIn($this->table . '.' . $this->column, $values);
        $this->groupBy($this->columnRight);
        $this->having(new Expression('COUNT(*) = ?', count($values)));

        return $this;
    }

    public function has($count = 1)
    {
        $this->columns([]);
        $this->groupBy($this->columnRight);
        $this->having(new Expression('COUNT(*) >= ?', (int) $count));

        return $this;
    }

    public function whereLike($column, $value, $not = false, $logical = 'and')
    {
        $this->columns([]);
        parent::whereLike($this->table . '.' . $column, $value, $not, $logical);

        return $this;
    }

    public function orWhereLike($column, $value, $not = false)
    {
        $this->whereLike($column, $value, $not, 'or');

        return $this;
    }
}