getDefaultMetadataCache() public static method

Gets the default metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable().
public static getDefaultMetadataCache ( ) : Zend_Cache_Core
return Zend_Cache_Core or null
示例#1
0
 public function testTableSetDefaultMetadataCacheRegistry()
 {
     $cache = $this->_getCache();
     Zend_Registry::set('registered_metadata_cache', $cache);
     Zend_Db_Table_Abstract::setDefaultMetadataCache('registered_metadata_cache');
     $this->assertSame($cache, Zend_Db_Table_Abstract::getDefaultMetadataCache());
 }
示例#2
0
 * @since      File available since Release 6.0
 * @author     David Soria Parra <*****@*****.**>
 */
// Force quotes off to run in cruisecontrol
ini_set("magic_quotes_gpc", 0);
ini_set("magic_quotes_runtime", 0);
ini_set("magic_quotes_sybase", 0);
/* use command line switches to overwrite this */
define("DEFAULT_CONFIG_FILE", "configuration.php");
define("PHPR_CONFIG_FILE", "configuration.php");
define("DEFAULT_CONFIG_SECTION", "testing-mysql");
define("PHPR_CONFIG_SECTION", "testing-mysql");
define('PHPR_ROOT_PATH', realpath(dirname(__FILE__) . '/../../'));
require_once PHPR_ROOT_PATH . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'Phprojekt.php';
Phprojekt::getInstance();
Zend_Db_Table_Abstract::getDefaultMetadataCache()->clean();
if (!defined('PHPUnit_MAIN_METHOD')) {
    define('PHPUnit_MAIN_METHOD', 'AllTests::main');
}
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
require_once 'PHPUnit/Util/Filter.php';
require_once 'Default/AllTests.php';
require_once 'Phprojekt/AllTests.php';
require_once 'Timecard/AllTests.php';
require_once 'History/AllTests.php';
require_once 'User/AllTests.php';
require_once 'Calendar/AllTests.php';
require_once 'Note/AllTests.php';
require_once 'Role/AllTests.php';
require_once 'Todo/AllTests.php';
示例#3
0
 /**
  * Gets content panel for the Debugbar
  *
  * @return string
  */
 public function getPanel()
 {
     if (!$this->_db) {
         return '';
     }
     $html = '<h4>Database queries';
     // @TODO: This is always on?
     if (Zend_Db_Table_Abstract::getDefaultMetadataCache()) {
         $html .= ' – Metadata cache ENABLED';
     } else {
         $html .= ' – Metadata cache DISABLED';
     }
     $html .= '</h4>';
     return $html . $this->getProfile();
 }
示例#4
0
 /**
  * Gets content panel for the Debugbar
  *
  * @return string
  */
 public function getPanel()
 {
     if (!$this->_db) {
         return '';
     }
     $html = '<h4>Database queries</h4>';
     if (Zend_Db_Table_Abstract::getDefaultMetadataCache()) {
         $html .= 'Metadata cache is ENABLED';
     } else {
         $html .= 'Metadata cache is DISABLED';
     }
     foreach ($this->_db as $name => $adapter) {
         if ($profiles = $adapter->getProfiler()->getQueryProfiles()) {
             $html .= '<h4>Adapter ' . $name . '</h4><ol>';
             foreach ($profiles as $profile) {
                 $html .= '<li><strong>[' . round($profile->getElapsedSecs() * 1000, 2) . ' ms]</strong> ' . htmlspecialchars($profile->getQuery()) . '</li>';
             }
             $html .= '</ol>';
         }
     }
     return $html;
 }
示例#5
0
 /**
  * Gets content panel for the Debugbar
  *
  * @return string
  */
 public function getPanel()
 {
     if (!$this->_db) {
         return '';
     }
     $html = '<h4>Database queries</h4>';
     if (Zend_Db_Table_Abstract::getDefaultMetadataCache()) {
         $html .= 'Metadata cache is ENABLED';
     } else {
         $html .= 'Metadata cache is DISABLED';
     }
     # For adding quotes to query params
     function add_quotes(&$value, $key)
     {
         $value = "'" . $value . "'";
     }
     foreach ($this->_db as $name => $adapter) {
         if ($profiles = $adapter->getProfiler()->getQueryProfiles()) {
             $adapter->getProfiler()->setEnabled(false);
             $html .= '<h4>Adapter ' . $name . '</h4><ol>';
             foreach ($profiles as $profile) {
                 $params = $profile->getQueryParams();
                 array_walk($params, 'add_quotes');
                 $paramCount = count($params);
                 if ($paramCount) {
                     $html .= '<li>' . htmlspecialchars(preg_replace(array_fill(0, $paramCount, '/\\?/'), $params, $profile->getQuery(), 1));
                 } else {
                     $html .= '<li>' . htmlspecialchars($profile->getQuery());
                 }
                 $html .= '<p><strong>Time:</strong> ' . round($profile->getElapsedSecs() * 1000, 2) . ' ms' . $this->getLinebreak();
                 $supportedAdapter = $adapter instanceof Zend_Db_Adapter_Mysqli || $adapter instanceof Zend_Db_Adapter_Pdo_Mysql;
                 # Run explain if enabled, supported adapter and SELECT query
                 if ($this->_explain && $supportedAdapter && Zend_Db_Profiler::SELECT == $profile->getQueryType()) {
                     $explain = $adapter->fetchRow('EXPLAIN ' . $profile->getQuery());
                     $html .= '<strong>Type:</strong> ' . strtolower($explain['select_type']) . ', ' . $explain['type'] . $this->getLinebreak() . '<strong>Possible Keys:</strong> ' . $explain['possible_keys'] . $this->getLinebreak() . '<strong>Key Used:</strong> ' . $explain['key'] . $this->getLinebreak() . '<strong>Rows:</strong> ' . $explain['rows'] . $this->getLinebreak() . '<strong>Extra:</strong> ' . $explain['Extra'];
                 }
                 $html .= '</p></li>';
             }
             $html .= '</ol>';
         }
     }
     return $html;
 }
示例#6
0
 /**
  * Ensures that Zend_Db_Table_Abstract::setDefaultMetadataCache() performs as expected
  *
  * @return void
  */
 public function testTableSetDefaultMetadataCache()
 {
     $cache = $this->_getCache();
     Zend_Db_Table_Abstract::setDefaultMetadataCache($cache);
     $this->assertSame($cache, Zend_Db_Table_Abstract::getDefaultMetadataCache());
     Zend_Db_Table_Abstract::setDefaultMetadataCache();
     $this->assertNull(Zend_Db_Table_Abstract::getDefaultMetadataCache());
 }
示例#7
0
    /**
     * Gets content panel for the Debugbar
     *
     * @return string
     */
    public function getPanel()
    {
        if (!$this->_db)
            return '';

        $html = '<h4>Requêtes sur la base de données</h4>';
        if (Zend_Db_Table_Abstract::getDefaultMetadataCache ()) {
            $html .= 'Cache de Métadonnées ACTIF';
        } else {
            $html .= 'Cache de Métadonnées INACTIF';
        }

        foreach ($this->_db as $name => $adapter) {
            if ($profiles = $adapter->getProfiler()->getQueryProfiles()) {
                $html .= '<h4>Adaptateur '.$name.'</h4><ol>';
                foreach ($profiles as $profile) {
                    $html .= '<li><strong>['.round($profile->getElapsedSecs()*1000, 2).' ms]</strong> '
                             .htmlspecialchars($profile->getQuery()).'</li>';
                }
                $html .= '</ol>';
            }
        }

        return $html;
    }
示例#8
0
 public function setUp()
 {
     parent::setUp();
     Phprojekt::getInstance();
     Zend_Db_Table_Abstract::getDefaultMetadataCache()->clean();
 }
示例#9
0
 /**
  * Check the current Fields and make the sync in the table of the module.
  *
  * @param array  $newFields Array with all the data per new field.
  * @param string $tableName Name of the module Table.
  * @param array  $tableData Array with the table data definition per new field.
  *
  * @return boolean True on a sucessful sync.
  */
 public function syncTable($newFields, $tableName, $tableData)
 {
     $systemFields = array('id', 'owner_id', 'project_id');
     $tableManager = new Phprojekt_Table(Phprojekt::getInstance()->getDb());
     // Clean the metadata cache
     if (null !== $this->_model) {
         $info = $this->_model->info();
         $dbConfig = Phprojekt::getInstance()->getDb()->getConfig();
         // Define the cache identifier where the metadata are saved
         $cacheId = md5((isset($dbConfig['options']['port']) ? ':' . $dbConfig['options']['port'] : null) . (isset($dbConfig['options']['host']) ? ':' . $dbConfig['options']['host'] : null) . '/' . $dbConfig['dbname'] . ':' . $info['schema'] . '.' . $info['name']);
         Zend_Db_Table_Abstract::getDefaultMetadataCache()->remove($cacheId);
     }
     $oldFields = $this->getDataDefinition();
     $tableDataForCreate['id'] = array('type' => 'auto_increment', 'length' => 11);
     $tableDataForCreate['owner_id'] = array('type' => 'int', 'length' => 11);
     if (!isset($tableDataForCreate['project_id'])) {
         $tableDataForCreate['project_id'] = array('type' => 'int', 'length' => 11);
     }
     array_merge($tableDataForCreate, $tableData);
     $tableName = strtolower(self::convertTableField($tableName));
     $tableFields = $tableManager->getTableFields($tableName, $tableDataForCreate);
     // Search for Modify and Delete
     $return = true;
     foreach ($oldFields as $oldValues) {
         $found = false;
         foreach ($newFields as $newValues) {
             if ($oldValues['id'] == $newValues['id']) {
                 $newValues['tableField'] = self::convertTableField($newValues['tableField']);
                 $fieldDefinition = $tableData[$newValues['tableField']];
                 $fieldDefinition['name'] = $newValues['tableField'];
                 if (!in_array($fieldDefinition['name'], $systemFields)) {
                     if ($oldValues['tableField'] == $newValues['tableField']) {
                         if (!$tableManager->modifyField($tableName, $fieldDefinition)) {
                             $return = false;
                         }
                     } else {
                         $fieldDefinition['oldName'] = $oldValues['tableField'];
                         if (!$tableManager->changeField($tableName, $fieldDefinition)) {
                             $return = false;
                         }
                     }
                 }
                 $found = true;
                 break;
             }
         }
         if (!$found) {
             $fieldDefinition = array();
             $fieldDefinition['name'] = $oldValues['tableField'];
             if (!in_array($fieldDefinition['name'], $systemFields)) {
                 if (!$tableManager->deleteField($tableName, $fieldDefinition)) {
                     $return = false;
                 }
             }
         }
     }
     // Search for Add
     foreach ($newFields as $newValues) {
         if ($newValues['id'] == 0) {
             $newValues['tableField'] = self::convertTableField($newValues['tableField']);
             $fieldDefinition = $tableData[$newValues['tableField']];
             $fieldDefinition['name'] = $newValues['tableField'];
             if (!in_array($fieldDefinition['name'], $systemFields)) {
                 if (!$tableManager->addField($tableName, $fieldDefinition)) {
                     $return = false;
                 }
             }
         }
     }
     return $return;
 }
示例#10
0
 public function install()
 {
     parent::install();
     $languageModule = new RM_Languages();
     $languages = $languageModule->fetchAll();
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'EmailNotifications.php';
     $model = new RM_EmailNotifications();
     foreach ($languages as $language) {
         if ($language->iso !== 'en_GB') {
             $model->addLanguage($language->iso);
         }
     }
     //Currently we just added extra columns and need to clean cache
     Zend_Db_Table_Abstract::getDefaultMetadataCache()->clean();
     //Copy en_GB default value to all other languages
     $emailNotification = $model->fetchByName('ReservationCompleteSuccessful', RM_EmailNotifications::REGULAR_USER);
     foreach ($languages as $language) {
         $iso = $language->iso;
         if ($iso !== 'en_GB') {
             $emailNotification->{$iso} = $emailNotification->en_GB;
         }
     }
     $emailNotification->save();
 }