CRUDlex\MySQLData::hasChildren PHP Method

hasChildren() protected method

Checks whether the by id given entity still has children referencing it.
protected hasChildren ( integer $id ) : boolean
$id integer the current entities id
return boolean true if the entity still has children
    protected function hasChildren($id)
    {
        foreach ($this->definition->getChildren() as $child) {
            $queryBuilder = $this->database->createQueryBuilder();
            $queryBuilder->select('COUNT(id)')->from('`' . $child[0] . '`', '`' . $child[0] . '`')->where('`' . $child[1] . '` = ?')->andWhere('deleted_at IS NULL')->setParameter(0, $id);
            $queryResult = $queryBuilder->execute();
            $result = $queryResult->fetch(\PDO::FETCH_NUM);
            if ($result[0] > 0) {
                return true;
            }
        }
        return false;
    }