Classe methods: remove reducdancy
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Provides getStockTables() — discovers td_stock_* tables scoped to this
|
||||
* company's active and historical warehouses via an information_schema JOIN.
|
||||
*
|
||||
* Requires the using class to expose:
|
||||
* $this->pdo PDO
|
||||
* $this->company_id int
|
||||
*/
|
||||
trait StockTablesTrait
|
||||
{
|
||||
private function getStockTables(): array
|
||||
{
|
||||
$sth = $this->pdo->prepare(
|
||||
"SELECT t.table_name
|
||||
FROM md_warehouse w
|
||||
JOIN information_schema.tables t
|
||||
ON t.table_schema = DATABASE()
|
||||
AND t.table_name = CONCAT('td_stock_', w.id)
|
||||
WHERE w.company_id = :company_id"
|
||||
);
|
||||
$sth->execute([':company_id' => $this->company_id]);
|
||||
return $sth->fetchAll(PDO::FETCH_COLUMN);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user