table() public method

Gets table name which is associated with the entity
public table ( string $alias = null ) : string
$alias string optional The table alias
return string The name of the database table
Ejemplo n.º 1
0
 /**
  * Creates partitions
  */
 public function create()
 {
     $db = $this->entity->db();
     $dt = new \DateTime('tomorrow');
     $end = new \DateTime('+1 month');
     $interval = new \DateInterval("P1D");
     $patritionSet = '';
     while ($dt <= $end) {
         $patritionSet .= "PARTITION p" . $dt->format('Ymd') . " VALUES LESS THAN (UNIX_TIMESTAMP('" . $dt->format('Y-m-d') . " 00:00:00')),";
         $dt->add($interval);
     }
     $this->_disableChecks();
     try {
         $this->entity->db()->Execute("\n                ALTER TABLE " . $this->entity->table() . "\n                PARTITION BY RANGE(UNIX_TIMESTAMP(" . $this->field->getColumnName() . ")) (" . rtrim($patritionSet, ',') . ")\n            ");
     } catch (\Exception $e) {
         $this->_enableChecks();
         throw $e;
     }
     $this->_enableChecks();
 }