Exemple #1
0
 protected function addTable(Table $table)
 {
     $this->tables[$table->getName()] = $table;
     return $this;
 }
 /**
  * @param  Table|string $table
  * @return Manager
  * @throws \Exception
  */
 public function getManager($table)
 {
     $structure = $this->getStructure();
     if ($table instanceof Table) {
         $tableName = $table->getName();
     } else {
         $tableName = $table;
     }
     if (!$structure->hasTable($tableName)) {
         throw new \Exception("数据表 %{$tableName} 不存在");
     }
     if (!isset($this->managers[$tableName])) {
         $this->managers[$tableName] = new Manager($this, $this->getStructure()->getTable($tableName));
     }
     return $this->managers[$tableName];
 }
Exemple #3
0
 public function getTableName()
 {
     return $this->table->getName();
 }
Exemple #4
0
 public static function getManyToManyTableName(Table $table1, Table $table2)
 {
     $relation = [$table1->getName(), $table2->getName()];
     sort($relation);
     return $relation[0] . '_' . $relation[1];
 }