private function getTagIdByName( $tag )
    {
        $tagSql = $this->sql( $this->getTableInSchema( static::$tagTableName ) );

        $select = $tagSql->select()
                         ->columns( array( 'id' ) )
                         ->where( array(
                             new TypedParameters(
                                 'LOWER(?) = ?',
                                 array(
                                     'name',
                                     mb_strtolower( $tag, 'UTF-8' ),
                                 ),
                                 array(
                                     TypedParameters::TYPE_IDENTIFIER,
                                     TypedParameters::TYPE_VALUE,
                                 )
                             ),
                         ) );

        $result = $tagSql->prepareStatementForSqlObject( $select )
                         ->execute();

        foreach ( $result as $row )
        {
           return $row['id'];
        }

        return null;
    }