Ubiquity 2.5.2
php rapid development framework
Loading...
Searching...
No Matches
TableExport.php
Go to the documentation of this file.
1<?php
2
3namespace Ubiquity\db\export;
4
7
16class TableExport extends DataExport{
17 protected $model;
18 protected $metas;
19 public function __construct($model,$batchSize=20){
20 parent::__construct($batchSize);
21 $this->model=$model;
22 $this->batchSize=$batchSize;
23 }
24
25 public function exports(DbExport $dbExport,$condition=""){
26 $table=OrmUtils::getTableName($this->model);
27 $this->metas=OrmUtils::getModelMetadata($this->model);
28 $manyToManys=[];
29 if(isset($this->metas["#manyToMany"]))
30 $manyToManys=$this->metas["#manyToMany"];
31 $this->scanManyToManys($dbExport, $manyToManys);
32 $fields=\array_diff($this->metas["#fieldNames"],$this->metas["#notSerializable"]);
33 $datas=DAO::getAll($this->model,$condition);
34 return $this->generateInsert($table, $fields, $datas);
35 }
36
37 protected function scanManyToManys(DbExport $dbExport,$manyToManys){
38 foreach ($manyToManys as $member=>$manyToMany){
39 if(isset($this->metas["#joinTable"][$member])){
40 $annotJoinTable=$this->metas["#joinTable"][$member];
41 $dbExport->addManyToMany($annotJoinTable["name"], ["member"=>$member,"class"=>$this->model]);
42 }
43 }
44 }
45}
generateInsert($table, $fields, $datas)
addManyToMany($jointable, $memberTargetEntity)
Definition DbExport.php:44
exports(DbExport $dbExport, $condition="")
scanManyToManys(DbExport $dbExport, $manyToManys)
__construct($model, $batchSize=20)
Gateway class between database and object model.
Definition DAO.php:33
Object/relational mapping utilities.
Definition OrmUtils.php:17
static getTableName($class)
Definition OrmUtils.php:45
static getModelMetadata($className)
Definition OrmUtils.php:21