예제 #1
0
 /**
  * Delete an alert type by ID.
  *
  * @param int $id The ID of the alert type.
  *
  * @return bool Whether the alert type was deleted.
  */
 public function deleteById($id = 0)
 {
     $id = (int) $id;
     $queryResult = (bool) $this->db->delete_query('alert_types', "id = {$id}");
     $this->getAlertTypes(true);
     return $queryResult;
 }
예제 #2
0
 /**
  * Gets the number of pages of a list.
  *
  * @param array $data Array containing the data to seek as 'field' => 'value'.
  * @return int Returns the number of pages in a list or FALSE on error.
  */
 function NumPages($data = NULL)
 {
     $sel = array('fields' => array('cnt' => 'COUNT(*)'), 'from' => array($this->name_db));
     if (!empty($data)) {
         $where = '';
         foreach ($this->fields as $field) {
             if (isset($data[$field->name_form])) {
                 $where .= (strlen($where) ? ' AND ' : '') . $field->Where($data[$field->name_form]);
             }
         }
         if (strlen($where)) {
             $sel['where'] = $where;
         }
     }
     if (!($rs = $this->db->Select($sel))) {
         $this->error = TB_ERR_DB;
         return FALSE;
     }
     if (($row = $rs->Row()) === FALSE) {
         $this->error = TB_ERR_DB;
         return FALSE;
     }
     $rs->Close();
     return (int) ceil($row['cnt'] / $this->list_recspage);
 }
예제 #3
0
 /**
  * Outputs the page to the client.
  *
  * @param string $page Page to show.
  */
 function Show($page)
 {
     if (empty($this->pages[$page])) {
         trigger_error("Page not found: {$page}");
         return;
     }
     if (isset($this->pages[$page]['layout'])) {
         $layout = $this->pages[$page]['layout'];
     } else {
         $layout = $this->layout;
     }
     if (isset($this->pages[$page]['style'])) {
         $style = $this->pages[$page]['style'];
     } else {
         $style = $this->styles;
     }
     if (isset($this->pages[$page]['title'])) {
         $title = $this->pages[$page]['title'];
     } else {
         $title = $this->title;
     }
     if (isset($this->pages[$page]['opts'])) {
         $opts = $this->pages[$page]['opts'];
     } else {
         $opts = array();
     }
     if ($this->db) {
         $this->db->Connect();
         $opts['db'] =& $this->db;
     }
     $pg =& new SEC_Page(array('header' => array('class' => 'SEC_Header', 'opts' => array('title' => $title, 'styles' => $style)), 'layout' => $layout, 'content' => array('class' => $this->pages[$page]['class'], 'opts' => $opts)));
     $pg->Show();
     $this->db->Close();
 }
예제 #4
0
 private static function db_connect()
 {
     $dsn = array("dsn" => _DB_TYPE . ':dbname=' . _DB_NAME . ';host=' . _DB_HOST, "phptype" => _DB_TYPE, "username" => _DB_USER, "password" => _DB_PASS, "hostspec" => _DB_HOST, "database" => _DB_NAME);
     self::$pdo = new PDO($dsn['dsn'], $dsn['username'], $dsn['password']);
     //静的プレースホルダ
     //self::$pdo->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
     //フェッチモードを指定
     self::$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
 }
예제 #5
0
 /**
  * Constructor: Load all parameters into member variables.
  *
  * @param array $opts Parameters for the object, as 'var' => 'value'.
  */
 function APP_Base($opts = array())
 {
     $keys = array_keys($opts);
     foreach ($keys as $key) {
         $this->{$key} = $opts[$key];
     }
     if (!empty($this->connection_class)) {
         $db_class = $this->connection_class;
         include_once $db_class . '.class.php';
         $this->db = new $db_class($this->connection_opts);
         $this->db->Connect();
     }
 }
예제 #6
0
 /**
  * Make the connection to the database
  *
  * @param array $components Results of parse_url()
  * @throws Exception
  */
 public function __construct($components)
 {
     parent::__construct($components);
     if ($this->persist && function_exists('mysql_pconnect')) {
         $this->connection = @mysql_pconnect($this->hostPort, $this->username, $this->password);
     } elseif (function_exists('mysql_connect')) {
         $this->connection = @mysql_connect($this->hostPort, $this->username, $this->password);
     } else {
         throw new Exception('PHP does not have MySQL functions enabled');
     }
     if (false === $this->connection) {
         throw new Exception(mysql_error(), mysql_errno());
     }
 }
예제 #7
0
 /**
  * Make the connection to the database
  *
  * @param array $components Results of parse_url()
  * @throws Exception SQLite functions are not enabled
  * @throws Exception Error connecting to the database
  */
 public function __construct($components)
 {
     parent::__construct($components);
     $mode = 0666;
     // default for sqlite_open and sqlite_popen
     parse_str($components['query'], $options);
     if (isset($options['mode'])) {
         $mode = $options['mode'];
     }
     if ($this->persist && function_exists('sqlite_popen')) {
         $this->connection = @sqlite_popen('/' . $this->db, $mode, $errorMessage);
     } elseif (function_exists('sqlite_open')) {
         $this->connection = @sqlite_open('/' . $this->db, $mode, $errorMessage);
     } else {
         throw new Exception('PHP does not have SQLite functions enabled');
     }
     if (false === $this->connection) {
         throw new Exception($errorMessage);
     }
 }
예제 #8
0
 /**
  * Format the field for database insertion.
  *
  * @param string $field The data from the field to be formated.
  * @return string Returns the formated field.
  */
 function ConsistFormat(&$field)
 {
     return "'" . $this->db->AddSlashes($field) . "'";
 }
예제 #9
0
    {
        return FASE::send(MSG_LVL_NOTIFY, array($area, $msg, $data, $place));
    }
    public static function warn($area, $msg = null, $data = array(), $place = null)
    {
        return FASE::send(MSG_LVL_WARN, array($area, $msg, $data, $place));
    }
    public static function alert($area, $msg = null, $data = array(), $place = null)
    {
        return FASE::send(MSG_LVL_ALERT, array($area, $msg, $data, $place));
    }
}
/** Debugging (introspection, debugging messages display */
FASE::requires('std/meta');
/** Simple language extensions, such as call(), export() or func() */
FASE::requires('std/lang');
set_error_handler(array('FASE', 'error_handler'));
/** Application configuration */
FASE::requires('/config');
/** Compatibility with both php.ini "magic quotes" setting values */
Lang::handle_magic_quotes();
/** Initialize the session only if it was already started by loging in */
if (isset($_COOKIE['PHPSESSID'])) {
    FASE::requires('web/session');
    Session::init();
}
/** Database connection is defined in config.php */
if (defined('FASE_DATABASE_CFG')) {
    FASE::requires('data/db');
    DB_Base::connect(FASE_DATABASE_CFG);
}
예제 #10
0
 public function testGetColumns()
 {
     $db_base = new DB_Base();
     $this->assertEquals($db_base->getColumns(), array('ID' => null, 'tenantID' => null));
 }