-
Notifications
You must be signed in to change notification settings - Fork 26
Creating Index
Yo-An Lin edited this page Jan 23, 2016
·
3 revisions
DeclareSchema let you be able to define index in the schema class:
class ProductSchema extends DeclareSchema
{
public function schema()
{
$this->column('name')->varchar(32);
$this->column('identity')->varchar(32);
$this->index('idx_name', 'name');
}
}class ProductSchema extends DeclareSchema
{
public function schema()
{
$this->column('name')->varchar(32);
$this->column('identity')->varchar(32);
$this->index('idx_product_query', ['name', 'identity']);
}
}Using BTREE:
class ProductSchema extends DeclareSchema
{
public function schema()
{
$this->column('name')->varchar(32);
$this->column('identity')->varchar(32);
$this->index('idx_product_query', ['name', 'identity'], 'btree');
}
}Using HASH:
class ProductSchema extends DeclareSchema
{
public function schema()
{
$this->column('name')->varchar(32);
$this->column('identity')->varchar(32);
$this->index('idx_product_query', ['name', 'identity'], 'hash');
}
}$query = $this->index('idx_product_query'); // Returns SQLBuilder\Universal\Query\CreateIndexQuery$this->column('identity')->varchar(32)->unique();