eZ\Publish\Core\Persistence\Legacy\Tests\Content\Gateway\DoctrineDatabaseTest::countContentRelations PHP Method

countContentRelations() protected method

Counts the number of relations in the database.
protected countContentRelations ( integer $fromId = null, integer $toId = null ) : integer
$fromId integer
$toId integer
return integer
    protected function countContentRelations($fromId = null, $toId = null)
    {
        $query = $this->getDatabaseHandler()->createSelectQuery();
        $query->select('count(*)')->from('ezcontentobject_link');
        if ($fromId !== null) {
            $query->where('from_contentobject_id=' . $fromId);
        }
        if ($toId !== null) {
            $query->where('to_contentobject_id=' . $toId);
        }
        $statement = $query->prepare();
        $statement->execute();
        return (int) $statement->fetchColumn();
    }
DoctrineDatabaseTest