本文整理汇总了PHP中Store::getManager方法的典型用法代码示例。如果您正苦于以下问题:PHP Store::getManager方法的具体用法?PHP Store::getManager怎么用?PHP Store::getManager使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Store
的用法示例。
在下文中一共展示了Store::getManager方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: recursive
private function recursive($foreign, &$order)
{
foreach ($foreign as $f) {
$many = $this->store->getManager()->getConnection()->getSchemaManager()->listTableForeignKeys($f->getForeignTableName());
if (count($many) > 0) {
$this->recursive($many, $order);
if (!isset($order[$f->getForeignTableName()])) {
$order[$f->getForeignTableName()] = $f->getForeignTableName();
}
} else {
if (!isset($order[$f->getForeignTableName()])) {
$order[$f->getForeignTableName()] = $f->getForeignTableName();
}
}
}
}
示例2: save
/**
*
* Salva los datos con el nombre y ruta especificado
*
* $this->getStore()
* ->getExporter()
* ->setEntities(array(
* '\examples\exampleBundle\Model\Entity\Persona'
* ))
* ->save(__DIR__ . '/exportExample.php');
*
* @param string $file nombre del archivo a salvar con los datos
*/
public function save($file)
{
$definition = array();
foreach ($this->entities as $entity) {
$meta = $this->store->getManager()->getMetadataFactory()->getMetadataFor($entity);
$table = $meta->getTableName();
$association = $meta->associationMappings;
foreach ($association as $map) {
if (isset($map['joinTable']) and isset($map['joinTable']['name'])) {
$mapTable = $map['joinTable']['name'];
if (!isset($definition[$mapTable])) {
$resultmap = $this->store->getManager()->getConnection()->executeQuery("SELECT * FROM {$mapTable}");
$definition[$mapTable] = $resultmap->fetchAll(\PDO::FETCH_ASSOC);
}
}
}
$result = $this->store->getManager()->getConnection()->executeQuery("SELECT * FROM {$table}");
$definition[$table] = $result->fetchAll(\PDO::FETCH_ASSOC);
}
foreach ($this->tables as $table) {
$result = $this->store->getManager()->getConnection()->executeQuery("SELECT * FROM {$table}");
$definition[$table] = $result->fetchAll(\PDO::FETCH_ASSOC);
}
$time = date("F d Y h:i:s A");
file_put_contents($file, "<?php\n /**\n * THIS FILE IS GENERATED BY RAPTOR EXPORTER, TO EASLY UPLOAD THIS FILE AGAIN INTO THE \n * DATABASE USE THE IMPORTER CLASS.\n * \n * Generated {$time}\n */\n \n\$create=" . var_export($this->entities, true) . ";\n\$data=" . var_export($definition, true) . ";\n\n");
}
示例3: import
/**
*
* Importa los datos previamente salvados con el Exporter hacia la base de datos
* Esta funcion retorna TRUE si la rutina fue realizada con exito, FALSE en caso contrario
*
* $this->getStore()->getImporter()->createIfNotExist(true)->import(__DIR__.'/exportExample.php');
*
* @param string $file el archivo a subir
* @throws \Exception throws una excepcion cuando el archivo a subir no exista
* @return boolean
*/
public function import($file)
{
if (!file_exists($file)) {
throw new \Exception("The file especified in the Importer does not exist");
}
include $file;
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->store->getManager());
try {
$meta = array();
if ($this->create) {
foreach ($create as $class) {
$meta[] = $this->store->getManager()->getMetadataFactory()->getMetadataFor($class);
}
//$schemaTool->createSchema($meta);
$schemaTool->updateSchema($meta, true);
}
} catch (\Exception $exc) {
}
try {
$this->store->getManager()->getConnection()->beginTransaction();
$ord = new TableDependencyOrder(array_keys($data), $this->store);
$dependency = $ord->getOrder();
foreach ($dependency as $tableName) {
$rows = $data[$tableName];
// if($clearTable)
// $this->store->getManager()->getConnection()->executeQuery("DELETE FROM $tableName");
foreach ($rows as $row) {
$this->store->getManager()->getConnection()->insert($tableName, $row);
}
}
$this->store->getManager()->getConnection()->commit();
return true;
} catch (\Exception $exc) {
$this->errors = $exc->getMessage();
$this->store->getManager()->getConnection()->rollback();
return false;
}
}