本文整理汇总了PHP中Config::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::add方法的具体用法?PHP Config::add怎么用?PHP Config::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Config
的用法示例。
在下文中一共展示了Config::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildConfig
/**
* @param array $relations
* @return array
*/
private function buildConfig(array $data, $asField)
{
$config = new Config();
foreach ($data as $item) {
$config->add(explode('.', $item), $asField);
}
return $config;
}
示例2: RebuildPoll
function RebuildPoll($only = null, PDO $db = null)
{
if (!$db) {
global $db;
}
require_once './lib/config.php';
$lang = array();
$used = array();
if (!$only) {
foreach (scandir('lang') as $x) {
if (ctype_alnum($x)) {
$lang[] = $x;
}
}
} elseif (ctype_alnum($only)) {
$lang[] = $x;
} else {
return false;
}
$poll = $db->query('SELECT * FROM ' . PRE . 'polls WHERE access IN (\'' . join('\',\'', $lang) . '\') ORDER BY ID DESC')->fetchAll(2);
//ASSOC
foreach ($poll as $x) {
if (isset($used[$x['access']])) {
continue;
}
if (in_array($x['access'], $lang)) {
$o = $db->query('SELECT ID,a,num,color FROM ' . PRE . 'answers WHERE IDP=' . $x['ID'] . ' ORDER BY seq')->fetchAll(3);
$file = new Config('./cache/poll_' . $x['access'] . '.php');
$file->add('poll', $x);
$file->add('option', $o);
$file->save();
$used[$x['access']] = 1;
}
}
//Zbędne pliki cache
foreach ($lang as $x) {
if (!isset($used[$x]) && file_exists('./cache/poll_' . $x . '.php')) {
unlink('./cache/poll_' . $x . '.php');
}
}
}
示例3: bootstrap
public function bootstrap()
{
session_start();
ob_start();
error_reporting(E_ALL);
ini_set('display_errors', '1');
require '../vendor/autoload.php';
define('vibius_BASEPATH', dirname(__DIR__) . '/');
$this->aliasManager = new Vibius\Facade\AliasManager();
$this->aliasManager->registerAutoloader();
// add config from app/config.php
Config::add('config');
$this->aliasManager->registerAliasDeleter();
}
示例4: __construct
private function __construct()
{
require_once __DIR__ . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'index.php';
if (!is_array(Config\Variables::$data)) {
trigger_error('Invalid configuration: missing Config\\Variables::$data variable', E_USER_ERROR);
}
$CONSTANTS = ['MINIFICATION_ENABLED' => false, 'REDIS_HOST' => '', 'REDIS_PORT' => '', 'PUSHED_ENABLED' => false, 'PUSHED_IP6' => true, 'PUSHED_PORT' => 5667, 'MIN_LENGTH_USER' => 2, 'MIN_LENGTH_PASS' => 6, 'MIN_LENGTH_NAME' => 2, 'MIN_LENGTH_SURNAME' => 2, 'CAPTCHA_LEVEL' => 5, 'CAMO_KEY' => '', 'CAMO_HOST' => '', 'HTTPS_DOMAIN' => '', 'STATIC_DOMAIN' => '', 'LOGIN_SSL_ONLY' => false, 'MINIFICATION_JS_CMD' => 'uglifyjs %path% -c unused=false', 'POSTGRESQL_HOST' => -1, 'POSTGRESQL_DATA_NAME' => -1, 'POSTGRESQL_USER' => -1, 'POSTGRESQL_PASS' => -1, 'POSTGRESQL_PORT' => -1, 'SITE_HOST' => -1, 'SITE_NAME' => -1, 'MOBILE_HOST' => -1, 'ISSUE_GIT_KEY' => '', 'SMTP_SERVER' => -1, 'SMTP_PORT' => -1, 'SMTP_USER' => -1, 'SMTP_PASS' => -1];
foreach (Config\Variables::$data as $const_key => $const_val) {
if (!isset($CONSTANTS[$const_key])) {
trigger_error('Unknown constant: ' . $const_key, E_USER_ERROR);
}
Config::add($const_key, $const_val);
unset($CONSTANTS[$const_key]);
}
// second (and last) iteration
foreach ($CONSTANTS as $rkey => $rval) {
if ($rval === -1) {
trigger_error('Missing constant from your config: ' . $rkey, E_USER_ERROR);
}
Config::add($rkey, $rval);
}
}
示例5: array
$page2 = 'nav-testimonios';
require "template/header.php";
?>
<div class="container">
<div class="row">
<?php
require "template/nav_testimonios.php";
?>
<?php
if (Utils::checkPost("add")) {
if (Config::exist("bgtestimonios")) {
$edit = array("value" => File::upload("background"));
$confirm = Config::edit($edit, array("name", "=", "bgtestimonios"));
} else {
$new = array("name" => "bgtestimonios", "value" => File::upload("background"));
$confirm = Config::add($new);
}
}
?>
<div class="grid col-9">
<div class="row">
<form action="" method="post" enctype="multipart/form-data" >
<p><?php
if (isset($confirm) && $confirm > 0) {
echo "Modificación exitosa";
}
?>
</p>
<h3>Ingrese la imagen de fondo</h3>
示例6: join
$q = $correct ? join(',', $correct) : 0;
}
#Aktualizuj
try {
$db->beginTransaction();
$db->exec('UPDATE ' . PRE . 'polls SET num=num+1 WHERE ID=' . $id);
$db->exec('UPDATE ' . PRE . 'answers SET num=num+1 WHERE IDP=' . $id . ' AND ID IN (' . $q . ')');
$db->exec('INSERT INTO ' . PRE . 'pollvotes (user,ID) VALUES (' . $u . ',' . $id . ')');
$db->commit();
#Pobierz odpowiedzi
$o = $db->query('SELECT ID,a,num,color FROM ' . PRE . 'answers WHERE IDP=' . $id . ' ORDER BY seq')->fetchAll(3);
++$poll['num'];
#Zapisz nowe dane do pliku
require './lib/config.php';
$file = new Config('./cache/poll_' . LANG . '.php');
$file->add('poll', $poll);
$file->add('option', $o);
$file->save();
} catch (Exception $e) {
$view->message(22);
exit;
}
}
}
#Cookie
$voted[] = $id;
setcookie('voted', join('o', $voted), time() + 7776000);
#JS?
if (JS) {
$_GET['id'] = $id;
include 'mod/panels/poll.php';
示例7: count
}
require LANG_DIR . 'admCfg.php';
#Action: save
if ($_POST) {
$num = count($_POST['bad']);
$words1 = array();
$words2 = array();
for ($i = 0; $i < $num; ++$i) {
$words1[] = substr($_POST['bad'][$i], 0, 50);
$words2[] = substr($_POST['good'][$i], 0, 50);
}
#Load saver class
require './lib/config.php';
try {
$f = new Config('words');
$f->add('words1', $words1);
$f->add('words2', $words2);
$f->save();
$view->info($lang['saved']);
} catch (Exception $e) {
$view->info($lang['error'] . $e);
}
} else {
include './cfg/words.php';
$num = count($words1);
}
#FORM
$word = array();
for ($i = 0; $i < $num; ++$i) {
$word[] = array(clean($words1[$i]), clean($words2[$i]));
}
示例8: Config
// {
// self::params[$name] = $value;
// }
//
// public function get($name)
// {
// return isset($this->params[$name]) ? $this->params[$name] : null;
// }
//
// public function getAll()
// {
// return $this->params[$name];
// }
//
// public function set($name, $value)
// {
// if(isset($this->params[$name]))
// {
// $this->params[$name] = $value;
// }
// }
//}
//Context Component 1
$config = new Config();
$config->add('db_host', 'localhost');
var_dump($config->get('db_host'));
//Context Component 2
$config2 = new Config();
$config2->add('casche_host', 'localddhost');
var_dump($config2->get('casche_host'));
var_dump($config, $config2);
示例9: array
<?php
//defaule setting
$log = array('Logging' => array('save_path' => 'F:\\tmp', 'default_wirte_level' => Logging::LEVEL_INFO, 'level' => Logging::LEVEL_INFO, 'filename_prefix' => 'mytest', 'sys_id' => 'test_1', 'write_local' => TRUE, 'write_zmq' => FALSE));
Config::add($log);
Config::Add(array('DefaultMemcacheServers' => 'xxxx:xxxx,xxxx:xxx', 'zmqAPI' => array('Server' => array())));
示例10: exec
/**
* Comando específico para uso com PDO. Se PDO não está presente,
* chama $this->query.
*
* @param string $sql
* @return <type> Retorna resultado da operação
*/
public function exec($sql, $mode = '')
{
/**
* Timer init
*/
$sT = microtime(true);
/**
* Se a extensão PDO está ativada
*/
if ($this->PdoExtension()) {
/**
* Executa e retorna resultado
*/
$result = $this->conn->exec($sql);
/**
* Quando executado CREATE TABLE, retorno com sucesso é 0 e
* insucesso é false, não sendo possível diferenciar entre um e
* outro. Este hack dá um jeitinho nisto.
*/
if (in_array($mode, array('CREATE_TABLE', 'CREATE TABLE'))) {
if ($result == 0 and !is_bool($result)) {
$result = 1;
} else {
$result = false;
}
}
//return $result;
} else {
$return = mysql_query($sql);
}
/**
* Timer Init
*/
$eT = microtime(true);
Config::add("SQLs", array("sql" => $sql, "time" => $eT - $sT));
return $result;
}
示例11: unset
if (empty($opt['pubKey'])) {
unset($opt['pubKey']);
}
if (empty($opt['prvKey'])) {
unset($opt['prvKey']);
}
}
if ($opt['captcha'] != 1) {
if (empty($opt['sbKey'])) {
unset($opt['sbKey']);
}
}
require './lib/config.php';
try {
$f = new Config('main');
$f->add('cfg', $opt);
$f->save();
$cfg =& $opt;
$view->info($lang['saved']);
event('CONFIG');
include './admin/config.php';
return 1;
} catch (Exception $e) {
$view->info($e);
}
} else {
$opt =& $cfg;
}
include LANG_DIR . 'admCfg.php';
#Style
$skin = '';
示例12: array
<?php
$db_zones = array('localhost_one' => array('main' => array('host' => '127.0.0.1', 'user' => 'root', 'password' => 'ruoyi', 'database' => 'ruoyi_testone', 'charset' => 'utf8', 'port' => '3306'), 'query' => array(array('host' => '127.0.0.1', 'user' => 'root', 'password' => 'ruoyi', 'database' => 'ruoyi_testone', 'charset' => 'utf8', 'port' => '3306'), array('host' => '127.0.0.1', 'user' => 'root', 'password' => 'ruoyi', 'database' => 'ruoyi_testone', 'charset' => 'utf8', 'port' => '3306'))), 'key2' => array('main' => array('host' => 'x', 'user' => 'x', 'password' => 'x', 'database' => 'x', 'charset' => 'utf8', 'port' => '5432'), 'query' => array(array('host' => 'x', 'user' => 'x', 'password' => 'x', 'database' => 'x', 'charset' => 'utf8', 'port' => '5432'))), 'key3' => array('main' => array('host' => 'x', 'user' => 'x', 'password' => 'x', 'database' => 'x', 'charset' => 'utf8', 'port' => '3306'), 'query' => array(array('host' => 'x', 'user' => 'x', 'password' => 'x', 'database' => 'x', 'charset' => 'utf8', 'port' => '3306'))));
Config::add(array('DB_CONFIG' => $db_zones));
unset($db_zones);
示例13: find
//.........这里部分代码省略.........
$modelReturned = substr($campo, 0, $underlinePos);
$campoReturned = substr($campo, $underlinePos + 1, 100);
/**
* Codigo
*/
$tempResult[$i][$modelReturned][$campoReturned] = $valor;
}
$o++;
}
$i++;
}
$loopEndTime = microtime(true);
/**
* FORMATA VARIÁVEL LEGÍVEL E TRATÁVEL
*
* Monta estruturas de saída de acordo com o modo pedido
*
* O modo padrão é ALL conforme configurado nos parâmetros da função
*/
/**
* Verificação de existência de dados no DB
*/
if (empty($tempResult)) {
$tempResult = array();
}
/**
* Loop por cada item do banco de dados retornado
*/
$loopProcessments = 0;
foreach ($tempResult as $chave => $index) {
$hasManyResult = array();
foreach ($index as $model => $dados) {
/**
* Ajusta retorno da array de dados para um formato legível
* e de melhor visualização para posterior tratamento.
*/
/**
* hasMANY
*
* Se o model pertence à categoria hasMany do Model pai
*/
if (array_key_exists($model, $mainModel->hasMany)) {
$hasManyResult = $dados;
/**
* Se há valor na tabela filha
*/
if (!empty($hasManyResult[$mainModel->hasMany[$model]["foreignKey"]])) {
$registro[$hasManyResult[$mainModel->hasMany[$model]["foreignKey"]]][$model][] = $hasManyResult;
}
} else {
if (array_key_exists($model, $mainModel->hasOne)) {
if (!empty($dados[$mainModel->hasOne[$model]["foreignKey"]])) {
$registro[$index[get_class($mainModel)]["id"]][$model] = $dados;
}
} else {
$registro[$index[get_class($mainModel)]["id"]][$model] = $dados;
}
}
$loopProcessments++;
}
unset($hasManyResult);
//unset($mainId);
}
//echo "Quantidade de Loops: ". $loopProcessments."<br>";
$findEndTime = microtime(true);
$loopEndTime = empty($loopEndTime) ? microtime(true) : $loopEndTime;
//echo "Loop Time: ".($loopEndTime - $loopStartTime)."<br />";
Config::write("dataFormatted", $loopProcessments);
Config::write("modelLoops", $loopEndTime - $loopStartTime);
Config::add("findStartTime", array($findEndTime - $findStartTime));
//pr( array_ $registro);
/**
* MODOS
*/
/*
* First
*/
if ($mode == "first") {
$registro = reset($registro);
} else {
if ($mode == "list") {
if (!empty($registro)) {
foreach ($registro as $chave => $model) {
/*
* Usa-se reset pois há ainda outra array dentro de $valor, que
* é um model.
*/
$actualModel = reset($model);
$campoId = $actualModel["id"];
unset($actualModel["id"]);
$campoValor = reset($actualModel);
$tmp[$campoId] = $campoValor;
//reset( next($valor) );
}
$registro = $tmp;
}
}
}
return $registro;
}
示例14: buildConfig
function buildConfig(&$data)
{
$f = new Config('./cfg/db.php');
$f->add('db_db', $data['type']);
$f->add('db_d', $data['file'] ? $data['file'] : $data['db']);
$f->addConst('PRE', PRE);
$f->addConst('PATH', PATH);
$f->addConst('URL', URL);
$f->addConst('NICEURL', $this->urls);
#Only for MySQL
if ($data['type'] == 'mysql') {
$f->add('db_h', $data['host']);
$f->add('db_u', $data['user']);
$f->add('db_p', $data['pass']);
}
return $f->save();
}
示例15: Install
} else {
$setup[$name] = (double) $data['version'];
Install();
if (isset($_POST['m'])) {
$q = $db->prepare('INSERT INTO ' . PRE . 'mitems (menu,text,url,seq) VALUES (?,?,?,?)');
for ($i = 0, $num = count($_POST['mt']); $i < $num; ++$i) {
if (!empty($_POST['mt'][$i])) {
$q->execute(array($_POST['mid'][$i], $_POST['mt'][$i], $name, $_POST['mp'][$i]));
}
}
include './lib/mcache.php';
RenderMenu();
}
}
$o = new Config('plug');
$o->add('setup', $setup);
$o->save();
$db->commit();
unset($_SESSION['admenu']);
} catch (Exception $e) {
$view->info($e->getMessage());
return 1;
}
} else {
$opt = array();
$useOpt = isset($setup[$name]) ? 'o.del.' : 'o.add.';
$useOpt .= isset($data[$useOpt . LANG]) ? LANG : 'en';
if (isset($data[$useOpt])) {
$i = 0;
foreach (explode('+', $data[$useOpt]) as $o) {
$opt['o' . ++$i] = clean($o);