PMA\libraries\Index::singleton PHP Method

singleton() public static method

Creates(if not already created) and returns the corresponding Index object
public static singleton ( string $schema, string $table, string $index_name = '' ) : Index
$schema string database name
$table string table name
$index_name string index name
return Index corresponding Index object
    public static function singleton($schema, $table, $index_name = '')
    {
        Index::_loadIndexes($table, $schema);
        if (!isset(Index::$_registry[$schema][$table][$index_name])) {
            $index = new Index();
            if (strlen($index_name) > 0) {
                $index->setName($index_name);
                Index::$_registry[$schema][$table][$index->getName()] = $index;
            }
            return $index;
        } else {
            return Index::$_registry[$schema][$table][$index_name];
        }
    }

Usage Example

Esempio n. 1
0
 /**
  * Get index with index name
  *
  * @param string $index Index name
  *
  * @return Index
  */
 public function getIndex($index)
 {
     return Index::singleton($this->_db_name, $this->_name, $index);
 }