db() public méthode

Gets database instance associated with the entity
public db ( ) : ADODB_mysqli
Résultat ADODB_mysqli Database connection instance
Exemple #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();
 }