symfony에서 batch파일 작성
2010. 3. 11. 16:06ㆍ99. 정리전 - IT/17. Symfony 퉷퉷
<?php
define('SF_ROOT_DIR', realpath(dirname(__file__).'/..'));
define('SF_APP', 'rent');
//define('SF_ENVIRONMENT', 'prod');
define('SF_ENVIRONMENT', 'dev');
define('SF_DEBUG', true);
require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php');
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();
$con = Propel::getConnection();
$time_start=_microtime();
$sql = "
SELECT address_id, address_id_old
FROM master
";
$stmt = $con->prepareStatement($sql);
$rst = $stmt->executeQuery();
$list = array();
while($rst->next())
{
$row = $rst->getRow();
$sql = "
SELECT address_id as a, '".$row["address_id"]."' as b
FROM master2
WHERE address_id = '".$row["address_id_old"]."'
";
$stmt = $con->prepareStatement($sql);
$rst2 = $stmt->executeQuery();
while($rst2->next())
{
$row2 = $rst2->getRow();
array_push($list, array($row2["a"]=>$row2["b"]));
}
}
foreach($list as $k => $item) {
print_r($k.' '.$item.' '."\n");
}
echo "finishtime:".(_microtime() - $time_start)."\n";
function _microtime ( ) { return array_sum(explode(' ',microtime())); }
define('SF_ROOT_DIR', realpath(dirname(__file__).'/..'));
define('SF_APP', 'rent');
//define('SF_ENVIRONMENT', 'prod');
define('SF_ENVIRONMENT', 'dev');
define('SF_DEBUG', true);
require_once(SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php');
$databaseManager = new sfDatabaseManager();
$databaseManager->initialize();
$con = Propel::getConnection();
$time_start=_microtime();
$sql = "
SELECT address_id, address_id_old
FROM master
";
$stmt = $con->prepareStatement($sql);
$rst = $stmt->executeQuery();
$list = array();
while($rst->next())
{
$row = $rst->getRow();
$sql = "
SELECT address_id as a, '".$row["address_id"]."' as b
FROM master2
WHERE address_id = '".$row["address_id_old"]."'
";
$stmt = $con->prepareStatement($sql);
$rst2 = $stmt->executeQuery();
while($rst2->next())
{
$row2 = $rst2->getRow();
array_push($list, array($row2["a"]=>$row2["b"]));
}
}
foreach($list as $k => $item) {
print_r($k.' '.$item.' '."\n");
}
echo "finishtime:".(_microtime() - $time_start)."\n";
function _microtime ( ) { return array_sum(explode(' ',microtime())); }