Skip to content

Latest commit

 

History

History
223 lines (169 loc) · 3.42 KB

table.md

File metadata and controls

223 lines (169 loc) · 3.42 KB

PHP Database

Go back

Table

use MichaelRushton\Database\SQL\Components\Table;

$table = new Table('t1');
// t1

only

$table->only();
// ONLY t1

partition

$table->partition('p1');
// t1 PARTITION (p1)
$table->partition('p1', 'p2');
// t1 PARTITION (p1, p2)
$table->partition(['p1', 'p2']);
// t1 PARTITION (p1, p2)

forPortionOf

$table->forPortionOf('date_period', '2025-01-01', '2025-01-31');
// t1 FOR PORTION OF date_period FROM '2025-01-01' TO '2025-01-31'
$table->forPortionOf('date_period', new \DateTime('2025-01-01'), new \DateTime('2025-01-31'));
// t1 FOR PORTION OF date_period FROM '2025-01-01 00:00:00' TO '2025-01-31 00:00:00'

as

$table->as('t2');
// t1 t2

useIndex

$table->useIndex();
// t1 USE INDEX ()
$table->useIndex('i1');
// t1 USE INDEX (i1)
$table->useIndex('i1', 'i2');
// t1 USE INDEX (i1, i2)
$table->useIndex(['i1', 'i2']);
// t1 USE INDEX (i1, i2)

useIndexForOrderBy

$table->useIndexForOrderBy();
// t1 USE INDEX FOR ORDER BY ()
$table->useIndexForOrderBy('i1');
// t1 USE INDEX FOR ORDER BY (i1)
$table->useIndexForOrderBy('i1', 'i2');
// t1 USE INDEX FOR ORDER BY (i1, i2)
$table->useIndexForOrderBy(['i1', 'i2']);
// t1 USE INDEX FOR ORDER BY (i1, i2)

useIndexForGroupBy

$table->useIndexForGroupBy();
// t1 USE INDEX FOR GROUP BY ()
$table->useIndexForGroupBy('i1');
// t1 USE INDEX FOR GROUP BY (i1)
$table->useIndexForGroupBy('i1', 'i2');
// t1 USE INDEX FOR GROUP BY (i1, i2)
$table->useIndexForGroupBy(['i1', 'i2']);
// t1 USE INDEX FOR GROUP BY (i1, i2)

ignoreIndex

$table->ignoreIndex('i1');
// t1 IGNORE INDEX (i1)
$table->ignoreIndex('i1', 'i2');
// t1 IGNORE INDEX (i1, i2)
$table->ignoreIndex(['i1', 'i2']);
// t1 IGNORE INDEX (i1, i2)

ignoreIndexForOrderBy

$table->ignoreIndexForOrderBy('i1');
// t1 IGNORE INDEX FOR ORDER BY (i1)
$table->ignoreIndexForOrderBy('i1', 'i2');
// t1 IGNORE INDEX FOR ORDER BY (i1, i2)
$table->ignoreIndexForOrderBy(['i1', 'i2']);
// t1 IGNORE INDEX FOR ORDER BY (i1, i2)

ignoreIndexForGroupBy

$table->ignoreIndexForGroupBy('i1');
// t1 IGNORE INDEX FOR GROUP BY (i1)
$table->ignoreIndexForGroupBy('i1', 'i2');
// t1 IGNORE INDEX FOR GROUP BY (i1, i2)
$table->ignoreIndexForGroupBy(['i1', 'i2']);
// t1 IGNORE INDEX FOR GROUP BY (i1, i2)

forceIndex

$table->forceIndex('i1');
// t1 FORCE INDEX (i1)
$table->forceIndex('i1', 'i2');
// t1 FORCE INDEX (i1, i2)
$table->forceIndex(['i1', 'i2']);
// t1 FORCE INDEX (i1, i2)

forceIndexForOrderBy

$table->forceIndexForOrderBy('i1');
// t1 FORCE INDEX FOR ORDER BY (i1)
$table->forceIndexForOrderBy('i1', 'i2');
// t1 FORCE INDEX FOR ORDER BY (i1, i2)
$table->forceIndexForOrderBy(['i1', 'i2']);
// t1 FORCE INDEX FOR ORDER BY (i1, i2)

forceIndexForGroupBy

$table->forceIndexForGroupBy('i1');
// t1 FORCE INDEX FOR GROUP BY (i1)
$table->forceIndexForGroupBy('i1', 'i2');
// t1 FORCE INDEX FOR GROUP BY (i1, i2)
$table->forceIndexForGroupBy(['i1', 'i2']);
// t1 FORCE INDEX FOR GROUP BY (i1, i2)