SproutCMS

This is the code documentation for the SproutCMS project

function unique()

Verify that a slug is unique for a given table

Usage

void Slug::unique ( string $value , string $table , array $conditions );

Example

// Exclude the current record when checking uniqueness
$valid->check('slug', 'Slug::unique', 'pages', [['id', '!=', $page_id]]);

Arguments

  1. string $value
    The slug
  2. string $table
    The table to check, which must contain columns 'id', 'name', and 'slug'
  3. array $conditions
    Extra conditions to check, in the format prescribed by Pdb::buildClause

Exceptions thrown

  • ValidationException
    If the slug isn't unique in the table under the specified conditions
  • InvalidArgumentException
    If the $table argument is not a valid table name

Return value

  • void