Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
3126483bae | |||
da17b79291 | |||
f1eb97348c |
20
Config.php
Normal file → Executable file
20
Config.php
Normal file → Executable file
@ -13,13 +13,27 @@ class Config extends Registry
|
||||
{
|
||||
|
||||
private static $_class_name = 'Config';
|
||||
|
||||
static public function set($name, $value)
|
||||
|
||||
/**
|
||||
* Метод устанавливает параметры конфигурации
|
||||
* @param mixed $param
|
||||
* Имя параметра или параметры в массиве
|
||||
* @param mixed $value
|
||||
* Значение параметра. Не требуется, если передаются параметры в массиве
|
||||
*/
|
||||
static public function set($param, $value = null)
|
||||
{
|
||||
// Разбираю массив, если параметры переданы в массиве
|
||||
if (is_array($param)) {
|
||||
foreach ($param as $paramItem => $value) {
|
||||
self::set($paramItem, $value);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (is_array($value)) {
|
||||
$value = new ConfigArray($value);
|
||||
}
|
||||
self::getInstance()->offsetSet($name, $value);
|
||||
self::getInstance()->offsetSet($param, $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,4 @@
|
||||
<?php namespace Majestic\Model;
|
||||
use Majestic\Exception\GeneralException;
|
||||
|
||||
/**
|
||||
* @copyright NetMonsters <team@netmonsters.ru>
|
||||
* @link http://netmonsters.ru
|
||||
@ -38,7 +36,7 @@ abstract class DbDriver
|
||||
$required = array('database', 'username', 'password', 'hostname');
|
||||
foreach ($required as $option) {
|
||||
if (!isset($config[$option])) {
|
||||
throw new GeneralException('Configuration must have a "' . $option . '".');
|
||||
throw new \GeneralException('Configuration must have a "' . $option . '".');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,7 @@ class MySQLiStatement extends DbStatement
|
||||
if ($this->map === null) {
|
||||
$this->mapPlaceholders();
|
||||
}
|
||||
|
||||
if ($this->map) {
|
||||
if (is_array($this->map) && count($this->map) > 0) {
|
||||
if (!is_string($param) && !is_int($param)) {
|
||||
throw new \Majestic\Exception\GeneralException('Placeholder must be an integer or string');
|
||||
}
|
||||
@ -34,7 +33,6 @@ class MySQLiStatement extends DbStatement
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
protected function mapPlaceholders()
|
||||
|
@ -164,10 +164,9 @@ abstract class SqlModel extends Model
|
||||
* @param string $data Request
|
||||
* @param array $params Request parameters
|
||||
* @param CacheKey $cache_key Key for caching in
|
||||
* @param bool $returnNewInstance Return the instance of this filled from query
|
||||
* @return mixed
|
||||
*/
|
||||
protected function fetch($data, $params = array(), $cache_key = null, $returnFilledInstance = true)
|
||||
protected function fetch($data, $params = array(), $cache_key = null)
|
||||
{
|
||||
if (!$cache_key || !$result = $cache_key->get()) {
|
||||
$result = $this->query($data, $params)->fetch();
|
||||
@ -175,20 +174,6 @@ abstract class SqlModel extends Model
|
||||
$cache_key->set($result);
|
||||
}
|
||||
}
|
||||
|
||||
if ($result && $returnFilledInstance) {
|
||||
$instance = new $this;
|
||||
|
||||
foreach (get_object_vars($result) as $key => $value) {
|
||||
if ($key == 'table') {
|
||||
$key = 'table_field';
|
||||
}
|
||||
$instance->$key = $value;
|
||||
}
|
||||
|
||||
return $instance;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -265,4 +250,4 @@ abstract class SqlModel extends Model
|
||||
{
|
||||
return new SqlCriteria($this, $sql_expression, $sql_expression_params);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user