Console_Application
[ class tree: Console_Application ] [ index: Console_Application ] [ all elements ]

Source for file CreateTablesApplication.php

Documentation is available at CreateTablesApplication.php

  1. <?php
  2. /**
  3.  * MediaSearch
  4.  *
  5.  * LICENSE
  6.  *
  7.  * "THE BEER-WARE LICENSE" (Revision 42):
  8.  * "Sven Strittmatter" <ausserirdisch@sven-space.de> wrote this file.
  9.  * As long as you retain this notice you can do whatever you want with
  10.  * this stuff. If we meet some day, and you think this stuff is worth it,
  11.  * you can buy me a beer in return.
  12.  *
  13.  * $Author$
  14.  * $Revision$
  15.  *
  16.  * @category    MediaSearch
  17.  * @package     Console_Application
  18.  * @copyright   Copyright (c) 2009 Sven Strittmatter
  19.  */
  20.  
  21. /**
  22.  * AbstractDbApplication
  23.  *
  24.  * @see AbstractDbApplication
  25.  */
  26. require_once('AbstractDbApplication.php');
  27. /**
  28.  * MediaSearch_ConfigLoader
  29.  *
  30.  * @see MediaSearch_ConfigLoader
  31.  */
  32. require_once('MediaSearch/ConfigLoader.php');
  33.  
  34. /**
  35.  * Neequired to react on signals
  36.  * @link http://de.php.net/manual/en/function.pcntl-signal.php
  37.  */
  38. declare(ticks 1);
  39.  
  40. /**
  41.  * Creates the two neccessary tables FileMeta and KeyWord.
  42.  *
  43.  * Beware: Existing tables will be dropped.
  44.  *
  45.  * @see AbstractDbApplication
  46.  *
  47.  * @abstract
  48.  * @category   MediaSearch
  49.  * @package    Console_Application
  50.  * @uses       MediaSearch_ConfigLoader
  51.  * @uses       Console_Exception
  52.  * @copyright  Copyright (c) 2009 Sven Strittmatter
  53.  */
  54.     const TRACE_LELVEL = 5;
  55.  
  56.     /**
  57.      * Loads the configs for FileMeta and KeyWord and executes them.
  58.      * The configs are located from application/configs/sql/table.
  59.      *
  60.      * @access protected
  61.      */
  62.     protected function run({
  63.         $this->echoMsg('Initialize database connection...');
  64.         $dbAdapter $this->dbResource->getDbAdapter();
  65.         $this->echoMsg('Get config for table: FileMeta');
  66.         $sqlConfig MediaSearch_ConfigLoader::get('sql.table.FileMeta');
  67.         $sqlConfig->setPdo($dbAdapter->getConnection()$this->dbName);
  68.         $this->echoMsg('Execute sql config');
  69.         $sqlConfig->execute();
  70.  
  71.         $this->echoMsg('Get config for table: KeyWord');
  72.         $sqlConfig MediaSearch_ConfigLoader::get('sql.table.KeyWord');
  73.         $sqlConfig->setPdo($dbAdapter->getConnection()$this->dbName);
  74.         $this->echoMsg('Execute sql config');
  75.         $sqlConfig->execute();
  76.     }
  77.  
  78.     /**
  79.      * @see AbstractDbApplication::getHelpMessage
  80.      */
  81.     public function getHelpMessage($author 'Sven Strittmatter'$email 'ich@weltraumschaf.de'{
  82.         $message  'This script creates all neccessay database tables.' PHP_EOL;
  83.         $message .= PHP_EOL;
  84.         $message .= 'All configs from application/configs/sql/tables/ will be loaded ';
  85.         $message .= 'and executed in the database specified in application/configs/datapase.php' PHP_EOL;
  86.         $message .= PHP_EOL;
  87.     $message .= $this->getUsage(PHP_EOL;
  88.         $message .= PHP_EOL;
  89.            $message .= parent::getHelpMessage($author$email);
  90.  
  91.         throw new Console_Exception($message);
  92.     }
  93. }

Documentation generated on Mon, 17 Aug 2009 14:52:01 +0200 by phpDocumentor 1.4.2