Use Doctrine/DBAL in place of Zend_Db

This commit is contained in:
Michael RICOIS 2016-09-30 16:01:35 +02:00
parent 1218dd36cd
commit 178cef5c8a
3 changed files with 139 additions and 129 deletions

View File

@ -18,8 +18,8 @@ $displayUsage = false;
try { try {
$opts = new Zend_Console_Getopt(array( $opts = new Zend_Console_Getopt(array(
'help|?' => "Aide.", 'help|?' => "Aide.",
'list' => "List item.", 'list' => "List item.",
'generate|g=s' => "Generate the specify cache.", 'generate|g=s' => "Generate the specify cache.",
)); ));
$opts->parse(); $opts->parse();
} catch (Zend_Console_Getopt_Exception $e) { } catch (Zend_Console_Getopt_Exception $e) {
@ -62,26 +62,45 @@ if ( $opts->list ) {
exit; exit;
} }
// Database
$c = new Zend_Config($this->getOptions());
$config = new \Doctrine\DBAL\Configuration();
$connectionParams = array(
'dbname' => $c->profil->db->metier->params->dbname,
'user' => $c->profil->db->metier->params->username,
'password' => $c->profil->db->metier->params->password,
'host' => $c->profil->db->metier->params->host,
'charset' => 'utf8',
'driver' => 'pdo_mysql',
);
try {
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
} catch (\Doctrine\DBAL\DBALException $e) {
echo "Connection Database impossible.\n";
exit;
}
/** /**
* Cache des Tribunaux Bodacc * Cache des Tribunaux Bodacc
*/ */
if( $opts->generate == 'Tribunaux' ) { if( $opts->generate == 'Tribunaux' ) {
$c = new Zend_Config($application->getOptions()); $sql = "SELECT triCode, triNom, triCP, triSiret FROM jo.tribunaux WHERE triCode IS NOT NULL";
$db = Zend_Db::factory($c->profil->db->metier); $stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$result = $db->query("SELECT triCode, triNom, triCP, triSiret FROM jo.tribunaux WHERE triCode IS NOT NULL"); $fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/BodaccTribunaux.php','w');
$result->setFetchMode(Zend_Db::FETCH_OBJ);
$rows = $result->fetchAll();
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/BodaccTribunaux.php','w');
fwrite($fp, "<?php\n"); fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n"); fwrite($fp, "return array(\n");
if ( count($rows) > 0 ) { if ($stmt->rowCount() > 0) {
foreach($rows as $item) { foreach($result as $item) {
$dep = intval(substr($item->triCP,0,2)); $dep = intval(substr($item->triCP, 0, 2));
if ($dep==97 || $dep==98) $dep=intval(substr($item->triCP,0,3)); if ($dep == 97 || $dep == 98) {
$dep = intval(substr($item->triCP, 0, 3));
}
fwrite($fp, "\t'" . $item->triCode . "' => array("); fwrite($fp, "\t'" . $item->triCode . "' => array(");
fwrite($fp, "'nom'=>\"" . $item->triNom . "\", 'siret'=>\"".$item->triSiret."\", 'dep'=>\"".$dep."\""); fwrite($fp, "'nom'=>\"" . $item->triNom . "\", 'siret'=>\"".$item->triSiret."\", 'dep'=>\"".$dep."\"");
fwrite($fp, "),\n"); fwrite($fp, "),\n");
@ -95,18 +114,16 @@ if( $opts->generate == 'Tribunaux' ) {
*/ */
if ( $opts->generate == 'FctDir' ) { if ( $opts->generate == 'FctDir' ) {
$c = new Zend_Config($application->getOptions()); $sql = "SELECT codeFct, libelle FROM jo.bodacc_fonctions";
$db = Zend_Db::factory($c->profil->db->metier); $stmt = $conn->prepare($sql);
$stmt->execute();
$result = $db->query("SELECT codeFct, libelle FROM jo.bodacc_fonctions"); $result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$result->setFetchMode(Zend_Db::FETCH_OBJ);
$rows = $result->fetchAll();
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/FctDir.php','w'); $fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/FctDir.php','w');
fwrite($fp, "<?php\n"); fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n"); fwrite($fp, "return array(\n");
if ( count($rows) > 0 ) { if ($stmt->rowCount() > 0) {
foreach($rows as $item) { foreach($rows as $item) {
fwrite($fp, "\t'" . intval($item->codeFct) . "' => \"". $item->libelle . "\",\n"); fwrite($fp, "\t'" . intval($item->codeFct) . "' => \"". $item->libelle . "\",\n");
} }
@ -119,18 +136,16 @@ if ( $opts->generate == 'FctDir' ) {
*/ */
if ( $opts->generate == 'Evenements' ) { if ( $opts->generate == 'Evenements' ) {
$c = new Zend_Config($application->getOptions()); $sql = "SELECT codEven, libEven, Bodacc_Code, Rubrique, version, lienEtab FROM jo.tabEvenements";
$db = Zend_Db::factory($c->profil->db->metier); $stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$result = $db->query("SELECT codEven, libEven, Bodacc_Code, Rubrique, version, lienEtab FROM jo.tabEvenements"); $fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/Evenements.php','w');
$result->setFetchMode(Zend_Db::FETCH_OBJ);
$rows = $result->fetchAll();
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/Evenements.php','w');
fwrite($fp, "<?php\n"); fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n"); fwrite($fp, "return array(\n");
if ( count($rows) > 0 ) { if ($stmt->rowCount() > 0) {
foreach($rows as $item) { foreach($rows as $item) {
fwrite($fp, "\t'" . intval($item->codEven) . "' => array(\n"); fwrite($fp, "\t'" . intval($item->codEven) . "' => array(\n");
@ -151,18 +166,16 @@ if ( $opts->generate == 'Evenements' ) {
*/ */
if ( $opts->generate == 'Devises' ) { if ( $opts->generate == 'Devises' ) {
$c = new Zend_Config($application->getOptions()); $sql = "SELECT libDeviseBodacc, devIso FROM jo.bodacc_devises";
$db = Zend_Db::factory($c->profil->db->metier); $stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$result = $db->query("SELECT libDeviseBodacc, devIso FROM jo.bodacc_devises"); $fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/Devises.php','w');
$result->setFetchMode(Zend_Db::FETCH_OBJ);
$rows = $result->fetchAll();
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/Devises.php','w');
fwrite($fp, "<?php\n"); fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n"); fwrite($fp, "return array(\n");
if ( count($rows) > 0 ) { if ($stmt->rowCount() > 0) {
foreach($rows as $item) { foreach($rows as $item) {
fwrite($fp, "\t\"" . $item->libDeviseBodacc . "\" => \"" . $item->devIso ."\",\n"); fwrite($fp, "\t\"" . $item->libDeviseBodacc . "\" => \"" . $item->devIso ."\",\n");
} }
@ -175,18 +188,16 @@ if ( $opts->generate == 'Devises' ) {
*/ */
if ( $opts->generate == 'RncsTribunaux' ) { if ( $opts->generate == 'RncsTribunaux' ) {
$c = new Zend_Config($application->getOptions()); $sql = "SELECT triNumGreffe, triNom, triId, triCode FROM jo.tribunaux WHERE triNumGreffe IS NOT NULL";
$db = Zend_Db::factory($c->profil->db->metier); $stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$result = $db->query("SELECT triNumGreffe, triNom, triId, triCode FROM jo.tribunaux WHERE triNumGreffe IS NOT NULL"); $fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/RncsTribunaux.php','w');
$result->setFetchMode(Zend_Db::FETCH_OBJ);
$rows = $result->fetchAll();
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/RncsTribunaux.php','w');
fwrite($fp, "<?php\n"); fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n"); fwrite($fp, "return array(\n");
if ( count($rows) > 0 ) { if ($stmt->rowCount() > 0) {
foreach($rows as $item) { foreach($rows as $item) {
fwrite($fp, "\t" . intval($item->triNumGreffe) . " => array("); fwrite($fp, "\t" . intval($item->triNumGreffe) . " => array(");
fwrite($fp, "'Id'=>\"" . $item->triId . "\", 'Nom'=>\"".$item->triNom."\", 'Code'=>\"".$item->triCode."\""); fwrite($fp, "'Id'=>\"" . $item->triId . "\", 'Nom'=>\"".$item->triNom."\", 'Code'=>\"".$item->triCode."\"");
@ -201,18 +212,16 @@ if ( $opts->generate == 'RncsTribunaux' ) {
*/ */
if ( $opts->generate == 'DevisesInpi' ) { if ( $opts->generate == 'DevisesInpi' ) {
$c = new Zend_Config($application->getOptions()); $sql = "SELECT devInpi, devIso FROM jo.tabDevises WHERE devInpi>0 ORDER BY devInpi ASC";
$db = Zend_Db::factory($c->profil->db->metier); $stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$result = $db->query("SELECT devInpi, devIso FROM jo.tabDevises WHERE devInpi>0 ORDER BY devInpi ASC"); $fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/DevisesInpi.php','w');
$result->setFetchMode(Zend_Db::FETCH_OBJ);
$rows = $result->fetchAll();
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/DevisesInpi.php','w');
fwrite($fp, "<?php\n"); fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n"); fwrite($fp, "return array(\n");
if ( count($rows) > 0 ) { if ($stmt->rowCount() > 0) {
foreach($rows as $item) { foreach($rows as $item) {
fwrite($fp, "\t" . intval($item->devInpi) . " => \"" . $item->devIso . "\",\n"); fwrite($fp, "\t" . intval($item->devInpi) . " => \"" . $item->devIso . "\",\n");
} }
@ -225,18 +234,16 @@ if ( $opts->generate == 'DevisesInpi' ) {
*/ */
if ( $opts->generate == 'Jugements' ) { if ( $opts->generate == 'Jugements' ) {
$c = new Zend_Config($application->getOptions()); $sql = "SELECT codJugement, codEven FROM jo.tabJugeRncs";
$db = Zend_Db::factory($c->profil->db->metier); $stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$result = $db->query("SELECT codJugement, codEven FROM jo.tabJugeRncs"); $fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/Jugements.php','w');
$result->setFetchMode(Zend_Db::FETCH_OBJ);
$rows = $result->fetchAll();
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/Jugements.php','w');
fwrite($fp, "<?php\n"); fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n"); fwrite($fp, "return array(\n");
if ( count($rows) > 0 ) { if ($stmt->rowCount() > 0) {
foreach($rows as $item) { foreach($rows as $item) {
fwrite($fp, "\t" . intval($item->codJugement) . " => " . $item->codEven . ",\n"); fwrite($fp, "\t" . intval($item->codJugement) . " => " . $item->codEven . ",\n");
} }
@ -249,18 +256,16 @@ if ( $opts->generate == 'Jugements' ) {
*/ */
if ( $opts->generate == 'PaysInpi' ) { if ( $opts->generate == 'PaysInpi' ) {
$c = new Zend_Config($application->getOptions()); $sql = "SELECT codePaysInpi, codPays FROM jo.tabPays WHERE codePaysInpi>0 ORDER BY codePaysInpi ASC";
$db = Zend_Db::factory($c->profil->db->metier); $stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$result = $db->query("SELECT codePaysInpi, codPays FROM jo.tabPays WHERE codePaysInpi>0 ORDER BY codePaysInpi ASC"); $fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/PaysInpi.php','w');
$result->setFetchMode(Zend_Db::FETCH_OBJ);
$rows = $result->fetchAll();
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/PaysInpi.php','w');
fwrite($fp, "<?php\n"); fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n"); fwrite($fp, "return array(\n");
if ( count($rows) > 0 ) { if ($stmt->rowCount() > 0) {
foreach($rows as $item) { foreach($rows as $item) {
fwrite($fp, "\t" . intval($item->codePaysInpi) . " => \"" . $item->codPays . "\",\n"); fwrite($fp, "\t" . intval($item->codePaysInpi) . " => \"" . $item->codPays . "\",\n");
} }
@ -273,29 +278,27 @@ if ( $opts->generate == 'PaysInpi' ) {
*/ */
if ( $opts->generate == 'CodesNaf' ) { if ( $opts->generate == 'CodesNaf' ) {
$c = new Zend_Config($application->getOptions()); $sql = "SELECT codNaf700 AS naf, libNaf700 AS LibNaf FROM jo.tabNaf4";
$db = Zend_Db::factory($c->profil->db->metier); $stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesNaf.php','w'); $fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesNaf.php','w');
fwrite($fp, "<?php\n"); fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n"); fwrite($fp, "return array(\n");
if ($stmt->rowCount() > 0) {
$result = $db->query("SELECT codNaf700 AS naf, libNaf700 AS LibNaf FROM jo.tabNaf4");
$result->setFetchMode(Zend_Db::FETCH_OBJ);
$rows = $result->fetchAll();
if ( count($rows) > 0 ) {
foreach($rows as $item) { foreach($rows as $item) {
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->LibNaf . "\",\n"); fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->LibNaf . "\",\n");
} }
} }
$result = $db->query("SELECT codNaf5 AS naf, libNaf5 AS LibNaf FROM jo.tabNaf5"); $sql = "SELECT codNaf5 AS naf, libNaf5 AS LibNaf FROM jo.tabNaf5";
$result->setFetchMode(Zend_Db::FETCH_OBJ); $stmt = $conn->prepare($sql);
$rows = $result->fetchAll(); $stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
if ( count($rows) > 0 ) { if ($stmt->rowCount() > 0) {
foreach($rows as $item) { foreach($rows as $item) {
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->LibNaf. "\",\n"); fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->LibNaf. "\",\n");
} }
@ -309,18 +312,16 @@ if ( $opts->generate == 'CodesNaf' ) {
*/ */
if ( $opts->generate == 'CodesNace' ) { if ( $opts->generate == 'CodesNace' ) {
$c = new Zend_Config($application->getOptions()); $sql = "SELECT codNaf5 AS naf, libNaf5 AS LibNaf, codNaf1 FROM jo.tabNaf5";
$db = Zend_Db::factory($c->profil->db->metier); $stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$result = $db->query("SELECT codNaf5 AS naf, libNaf5 AS LibNaf, codNaf1 FROM jo.tabNaf5"); $fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesNace.php','w');
$result->setFetchMode(Zend_Db::FETCH_OBJ);
$rows = $result->fetchAll();
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesNace.php','w');
fwrite($fp, "<?php\n"); fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n"); fwrite($fp, "return array(\n");
if ( count($rows) > 0 ) { if ($stmt->rowCount() > 0) {
foreach($rows as $item) { foreach($rows as $item) {
fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->codNaf1 . preg_replace('/^0/','',substr($item->naf,0,4)) . "\",\n"); fwrite($fp, "\t'" . $item->naf . "' => \"" . $item->codNaf1 . preg_replace('/^0/','',substr($item->naf,0,4)) . "\",\n");
} }
@ -333,18 +334,16 @@ if ( $opts->generate == 'CodesNace' ) {
*/ */
if ( $opts->generate == 'CodesNafa' ) { if ( $opts->generate == 'CodesNafa' ) {
$c = new Zend_Config($application->getOptions()); $sql = "SELECT codNafa AS nafa, libNafa FROM jo.tabNafa";
$db = Zend_Db::factory($c->profil->db->metier); $stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$result = $db->query("SELECT codNafa AS nafa, libNafa FROM jo.tabNafa"); $fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesNafa.php','w');
$result->setFetchMode(Zend_Db::FETCH_OBJ);
$rows = $result->fetchAll();
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesNafa.php','w');
fwrite($fp, "<?php\n"); fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n"); fwrite($fp, "return array(\n");
if ( count($rows) > 0 ) { if ($stmt->rowCount() > 0) {
foreach($rows as $item) { foreach($rows as $item) {
fwrite($fp, "\t'" . $item->nafa . "' => \"" . $item->libNafa ."\",\n"); fwrite($fp, "\t'" . $item->nafa . "' => \"" . $item->libNafa ."\",\n");
} }
@ -357,18 +356,16 @@ if ( $opts->generate == 'CodesNafa' ) {
*/ */
if ( $opts->generate == 'CodesFJ' ) { if ( $opts->generate == 'CodesFJ' ) {
$c = new Zend_Config($application->getOptions()); $sql = "SELECT code AS FJ, libelle AS libFJ FROM jo.tabFJur WHERE code>=1000";
$db = Zend_Db::factory($c->profil->db->metier); $stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$result = $db->query("SELECT code AS FJ, libelle AS libFJ FROM jo.tabFJur WHERE code>=1000"); $fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesFJ.php','w');
$result->setFetchMode(Zend_Db::FETCH_OBJ);
$rows = $result->fetchAll();
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/CodesFJ.php','w');
fwrite($fp, "<?php\n"); fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n"); fwrite($fp, "return array(\n");
if ( count($rows) > 0 ) { if ($stmt->rowCount() > 0) {
foreach($rows as $item) { foreach($rows as $item) {
fwrite($fp, "\t" . $item->FJ . " => \"" . str_replace('"','\"',$item->libFJ) ."\",\n"); fwrite($fp, "\t" . $item->FJ . " => \"" . str_replace('"','\"',$item->libFJ) ."\",\n");
} }
@ -382,18 +379,16 @@ if ( $opts->generate == 'CodesFJ' ) {
*/ */
if ( $opts->generate == 'AffairesTypes' ) { if ( $opts->generate == 'AffairesTypes' ) {
$c = new Zend_Config($application->getOptions()); $sql = "SELECT code, label FROM jo.greffes_affaires_nature";
$db = Zend_Db::factory($c->profil->db->metier); $stmt = $conn->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$result = $db->query("SELECT code, label FROM jo.greffes_affaires_nature"); $fp = fopen(APPLICATION_PATH . '/../library/Metier/Table/AffairesTypes.php','w');
$result->setFetchMode(Zend_Db::FETCH_OBJ);
$rows = $result->fetchAll();
$fp=fopen(APPLICATION_PATH . '/../library/Metier/Table/AffairesTypes.php','w');
fwrite($fp, "<?php\n"); fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n"); fwrite($fp, "return array(\n");
if ( count($rows) > 0 ) { if ($stmt->rowCount() > 0) {
foreach($rows as $item) { foreach($rows as $item) {
fwrite($fp, "\t'" . $item->code . "' => \"" . $item->label ."\",\n"); fwrite($fp, "\t'" . $item->code . "' => \"" . $item->label ."\",\n");
} }
@ -406,18 +401,16 @@ if ( $opts->generate == 'AffairesTypes' ) {
*/ */
if ( $opts->generate == 'ProcolDelete' ) { if ( $opts->generate == 'ProcolDelete' ) {
$c = new Zend_Config($application->getOptions()); $sql = "SELECT codEven, affProcol FROM jo.tabEvenements WHERE affProcol>0";
$db = Zend_Db::factory($c->profil->db->metier); $stmt = $conn->prepare($sql);
$stmt->execute();
$result = $db->query("SELECT codEven, affProcol FROM jo.tabEvenements WHERE affProcol>0"); $result = $stmt->fetchAll(\PDO::FETCH_OBJ);
$result->setFetchMode(Zend_Db::FETCH_OBJ);
$rows = $result->fetchAll();
$fp = fopen(APPLICATION_PATH . '/../library/Metier/Defaillance/ProcolDelete.php', 'w'); $fp = fopen(APPLICATION_PATH . '/../library/Metier/Defaillance/ProcolDelete.php', 'w');
fwrite($fp, "<?php\n"); fwrite($fp, "<?php\n");
fwrite($fp, "return array(\n"); fwrite($fp, "return array(\n");
if ( count($rows) > 0 ) { if ($stmt->rowCount() > 0) {
foreach($rows as $item) { foreach($rows as $item) {
fwrite($fp, "\t" . $item->codEven . " => " . $item->affProcol .",\n"); fwrite($fp, "\t" . $item->codEven . " => " . $item->affProcol .",\n");
} }

View File

@ -55,11 +55,11 @@ Zend_Db_Table_Abstract::setDefaultAdapter($db);
define('LOG_PATH' , $c->profil->path->shared.'/log'); define('LOG_PATH' , $c->profil->path->shared.'/log');
if (isset($opts->ratios)){ if (isset($opts->ratios)) {
genereCacheRatios(); genereCacheRatios();
} }
if ( isset($opts->formules) ) { if (isset($opts->formules)) {
if ( isset($opts->type) && in_array($opts->type, array('score', 'valo')) ) { if ( isset($opts->type) && in_array($opts->type, array('score', 'valo')) ) {
$type = $opts->type; $type = $opts->type;

View File

@ -38,15 +38,33 @@ if ($displayUsage) {
} }
if ($opts->log) { if ($opts->log) {
$c = new Zend_Config($application->getOptions()); // Database
$db = Zend_Db::factory($c->profil->db->metier); $c = new Zend_Config($this->getOptions());
Zend_Db_Table::setDefaultAdapter($db); $config = new \Doctrine\DBAL\Configuration();
$sql = $db->select()->from('logs_item', '*', 'sdv1'); $connectionParams = array(
$stmt = $db->query($sql); 'dbname' => $c->profil->db->metier->params->dbname,
'user' => $c->profil->db->metier->params->username,
'password' => $c->profil->db->metier->params->password,
'host' => $c->profil->db->metier->params->host,
'charset' => 'utf8',
'driver' => 'pdo_mysql',
);
try {
$conn = \Doctrine\DBAL\DriverManager::getConnection($connectionParams, $config);
} catch (\Doctrine\DBAL\DBALException $e) {
echo "Connection Database impossible.\n";
exit;
}
$sql = "SELECT * FROM sdv1.logs_item";
$stmt = $conn->prepare($sql);
$stmt->execute();
$outPath = APPLICATION_PATH . '/../library/Scores/Account/Log/List.php'; $outPath = APPLICATION_PATH . '/../library/Scores/Account/Log/List.php';
$outFile = $outPath . '/Config.php'; $outFile = $outPath . '/Config.php';
if ($stmt->rowCount() > 0) { if ($stmt->rowCount() > 0) {
$result = $stmt->fetchAll(Zend_Db::FETCH_ASSOC); $result = $stmt->fetchAll(\PDO::FETCH_OBJ);
file_put_contents($outFile, "<?php\n"); file_put_contents($outFile, "<?php\n");
file_put_contents($outFile, "/* Auto generated ".date('Y-m-d H:i:s')." */\n"); file_put_contents($outFile, "/* Auto generated ".date('Y-m-d H:i:s')." */\n");
file_put_contents($outFile, "return array(\n", FILE_APPEND); file_put_contents($outFile, "return array(\n", FILE_APPEND);
@ -59,7 +77,6 @@ if ($opts->log) {
} }
file_put_contents($outFile, ");\n", FILE_APPEND); file_put_contents($outFile, ");\n", FILE_APPEND);
} }
} }