当前位置: 首页>>代码示例>>PHP>>正文


PHP CASHSystem::setSystemSetting方法代码示例

本文整理汇总了PHP中CASHSystem::setSystemSetting方法的典型用法代码示例。如果您正苦于以下问题:PHP CASHSystem::setSystemSetting方法的具体用法?PHP CASHSystem::setSystemSetting怎么用?PHP CASHSystem::setSystemSetting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CASHSystem的用法示例。


在下文中一共展示了CASHSystem::setSystemSetting方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_setSystemSetting

 function test_setSystemSetting()
 {
     // also tests findAndReplaceInFile()
     $control = CASHSystem::getSystemSettings('timezone');
     CASHSystem::setSystemSetting('timezone', 'Not really a timezone');
     $return = CASHSystem::getSystemSettings('timezone');
     $this->assertNotEqual($control, $return);
     $this->assertEqual('Not really a timezone', $return);
 }
开发者ID:nodots,项目名称:DIY,代码行数:9,代码来源:007_CASHSystem.php

示例2: array

<?php

$misc_message = false;
if (isset($_POST['domisc'])) {
    CASHSystem::setSystemSetting('timezone', $_POST['timezone']);
    CASHSystem::setSystemSetting('systememail', $_POST['systememail']);
    $cash_admin->page_data['page_message'] = 'Success. All changed.';
}
$migrate_message = false;
if (isset($_POST['domigrate'])) {
    $new_settings = array('hostname' => $_POST['hostname'], 'username' => $_POST['adminuser'], 'password' => $_POST['adminpassword'], 'database' => $_POST['databasename']);
    $migrate_request = new CASHRequest(array('cash_request_type' => 'system', 'cash_action' => 'migratedb', 'todriver' => $_POST['driver'], 'tosettings' => $new_settings));
    if ($migrate_request->response['payload']) {
        $cash_admin->page_data['page_message'] = 'Success. So that happened.';
    } else {
        $cash_admin->page_data['error_message'] = 'Error. There was a problem migrating your data.';
    }
}
$platform_settings = CASHSystem::getSystemSettings();
$cash_admin->page_data['system_email'] = $platform_settings['systememail'];
$cash_admin->page_data['timezone_options'] = AdminHelper::drawTimeZones($platform_settings['timezone']);
$db_types = array('mysql' => 'MySQL', 'sqlite' => 'SQLite');
$db_type = 'unknown';
if (array_key_exists($platform_settings['driver'], $db_types)) {
    $cash_admin->page_data['db_type'] = $db_types[$platform_settings['driver']];
}
if ($cash_admin->page_data['db_type'] == 'MySQL') {
    $cash_admin->page_data['migrate_from_mysql'] = true;
} elseif ($cash_admin->page_data['db_type'] == 'SQLite') {
    $cash_admin->page_data['migrate_from_sqlite'] = true;
}
开发者ID:blacktire,项目名称:DIY,代码行数:31,代码来源:settings.php

示例3: migrateDB

 public function migrateDB($todriver = 'mysql', $tosettings = false)
 {
     /* for mysql we're expecting a $tosettings array that looks like:
     		   hostname => hostname[:port]
     		   username => username
     		   password => password
     		   database => databasename
     		*/
     if ($todriver != 'mysql' || !is_array($tosettings)) {
         return false;
     } else {
         $newdb_hostname = false;
         $newdb_port = false;
         if (strpos($tosettings['hostname'], ':') === false) {
             $newdb_hostname = $tosettings['hostname'];
             $newdb_port = 3306;
         } else {
             if (substr($tosettings['hostname'], 0, 2) == ':/') {
                 $newdb_hostname = $tosettings['hostname'];
             } else {
                 $host_and_port = explode(':', $tosettings['hostname']);
                 $newdb_hostname = $host_and_port[0];
                 $newdb_port = $host_and_port[1];
             }
         }
         if ($newdb_hostname) {
             try {
                 if (substr($this->hostname, 0, 2) == ':/') {
                     $newdb = new PDO("{$todriver}:unix_socket={$newdb_hostname};dbname={$tosettings['database']}", $tosettings['username'], $tosettings['password']);
                 } else {
                     $newdb = new PDO("{$todriver}:host={$newdb_hostname};port={$newdb_port};dbname={$tosettings['database']}", $tosettings['username'], $tosettings['password']);
                 }
                 $newdb->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
             } catch (PDOException $e) {
                 return false;
             }
             // run the baseline sql file — will blow away any old bullshit but leave non-standard tables
             if ($newdb->query(file_get_contents(CASH_PLATFORM_ROOT . '/settings/sql/cashmusic_db.sql'))) {
                 // begin a transaction for the newdb
                 $newdb->beginTransaction();
                 // get all the current tables
                 $current_tables = $this->getRealTableNames();
                 foreach ($current_tables as $tablename) {
                     // looping through and starting the CRAAAAZZZZEEEEEE
                     // first get all data in the current table
                     $tabledata = $this->doQuery('SELECT * FROM ' . $tablename);
                     // now jam that junk into an insert on the new db
                     if (is_array($tabledata)) {
                         // we found data, so loop through each one with an insert
                         foreach ($tabledata as $data) {
                             $query = "INSERT INTO {$tablename} (";
                             $separator = '';
                             $query_columns = '';
                             $query_values = '';
                             foreach ($data as $fieldname => $value) {
                                 $query_columns .= $separator . $fieldname;
                                 $query_values .= $separator . ':' . $fieldname;
                                 $separator = ',';
                             }
                             $query .= "{$query_columns}) VALUES ({$query_values})";
                             try {
                                 $q = $newdb->prepare($query);
                                 $q->execute($data);
                             } catch (PDOException $e) {
                                 // something went wrong. roll back and quit
                                 $newdb->rollBack();
                                 return false;
                             }
                         }
                     }
                 }
                 // fuckin a right.
                 $result = $newdb->commit();
                 if ($result) {
                     CASHSystem::setSystemSetting('driver', $todriver);
                     CASHSystem::setSystemSetting('hostname', $tosettings['hostname']);
                     CASHSystem::setSystemSetting('username', $tosettings['username']);
                     CASHSystem::setSystemSetting('password', $tosettings['password']);
                     CASHSystem::setSystemSetting('database', $tosettings['database']);
                     return $result;
                 } else {
                     return $result;
                 }
             }
         } else {
             return false;
         }
     }
 }
开发者ID:blacktire,项目名称:DIY,代码行数:89,代码来源:CASHDBA.php


注:本文中的CASHSystem::setSystemSetting方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。