예제 #1
0
function check_db_error($sth, $file, $line)
{
    if (MDB2::isError($sth)) {
        $error_str = "File: {$file} (line {$line})<br />\n " . "<strong>" . $sth->getMessage() . "</strong><br />\n" . $sth->getUserInfo() . "<br />\n";
        die($error_str);
    }
}
 /**
  * update user data
  *
  * @param array $data
  * @return bool true or false on error
  */
 function perform($data)
 {
     $this->B->{$data}['error'] = FALSE;
     $error =& $this->B->{$data}['error'];
     $this->B->{$data}['result'] = array();
     $_result =& $this->B->{$data}['result'];
     $comma = '';
     foreach ($data['fields'] as $f) {
         $_fields .= $comma . $f;
         $comma = ',';
     }
     if (isset($data['order'])) {
         $_order = $data['order'];
     } else {
         $_order = 'rights DESC, lastname ASC';
     }
     $sql = "\n            SELECT\n                {$_fields}\n            FROM\n                {$this->B->sys['db']['table_prefix']}user_users\n            ORDER BY\n                {$_order}";
     $result = $this->B->db->query($sql);
     if (MDB2::isError($result)) {
         trigger_error($result->getMessage() . "\n" . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         $error = 'Unexpected error';
         return FALSE;
     }
     if (is_object($result)) {
         while ($row =& $result->fetchRow(MDB2_FETCHMODE_ASSOC)) {
             $tmp = array();
             foreach ($data['fields'] as $f) {
                 $tmp[$f] = stripslashes($row[$f]);
             }
             $_result[] = $tmp;
         }
     }
     return TRUE;
 }
 /**
  * Delete email list data and attachement folder
  *
  * @param array $data
  */
 function perform(&$data)
 {
     if (empty($data['lid'])) {
         trigger_error("'lid' is empty!\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     $set = '';
     $comma = '';
     foreach ($data['data'] as $key => $val) {
         $set .= $comma . $key . '=' . $val;
         $comma = ',';
     }
     $sql = '
         UPDATE 
             ' . $this->B->sys['db']['table_prefix'] . 'earchive_lists
         SET
             ' . $set . '
         WHERE
             lid=' . $data['lid'];
     $result = $this->B->db->query($sql);
     if (MDB2::isError($result)) {
         trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     return TRUE;
 }
예제 #4
0
 /**
  * Connect to specific database
  *
  * @param  string  DSN for DB connections
  * @return object  PEAR database handle
  * @access private
  */
 function dsn_connect($dsn)
 {
     // Use persistent connections if available
     $db_options = array('persistent' => $this->db_pconn, 'emulate_prepared' => $this->debug_mode, 'debug' => $this->debug_mode, 'debug_handler' => 'mdb2_debug_handler', 'portability' => MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL);
     if ($this->db_provider == 'pgsql') {
         $db_options['disable_smart_seqname'] = true;
         $db_options['seqname_format'] = '%s';
     }
     $dbh = MDB2::connect($dsn, $db_options);
     if (MDB2::isError($dbh)) {
         $this->db_error = TRUE;
         $this->db_error_msg = $dbh->getMessage();
         raise_error(array('code' => 500, 'type' => 'db', 'line' => __LINE__, 'file' => __FILE__, 'message' => $dbh->getUserInfo()), TRUE, FALSE);
     } else {
         if ($this->db_provider == 'sqlite') {
             $dsn_array = MDB2::parseDSN($dsn);
             if (!filesize($dsn_array['database']) && !empty($this->sqlite_initials)) {
                 $this->_sqlite_create_database($dbh, $this->sqlite_initials);
             }
         } else {
             $dbh->setCharset('utf8');
         }
     }
     return $dbh;
 }
 /**
  * update user data
  *
  * @param array $data
  * @return bool true or false on error
  */
 function perform($data)
 {
     $this->B->{$data}['error'] = FALSE;
     $error =& $this->B->{$data}['error'];
     $set = '';
     $comma = '';
     foreach ($data['fields'] as $key => $val) {
         $set .= $comma . $key . '="' . $this->B->db->escape($val) . '"';
         $comma = ',';
     }
     $sql = '
         UPDATE 
             ' . $this->B->sys['db']['table_prefix'] . 'user_users
         SET
             ' . $set . '
         WHERE
             uid=' . $data['user_id'];
     $result = $this->B->db->query($sql);
     if (MDB2::isError($result)) {
         trigger_error($result->getMessage() . "\n" . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         $error = 'Unexpected error';
         return FALSE;
     }
     return TRUE;
 }
 /**
  * add message data
  *
  * @param array $data
  */
 function perform(&$data)
 {
     $mid = $this->B->db->nextId($this->B->sys['db']['table_prefix'] . 'earchive_messages');
     if (MDB2::isError($mid)) {
         trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     $sql = '
         INSERT INTO 
             ' . $this->B->sys['db']['table_prefix'] . 'earchive_messages
             (mid,lid,sender,subject,mdate,body,folder)
         VALUES
             (' . $mid . ',
              ' . $data['lid'] . ',
              "' . $data['sender'] . '",
              "' . $data['subject'] . '",
              "' . $data['mdate'] . '",
              "' . $data['body'] . '",
              "' . $data['folder'] . '")';
     $result = $this->B->db->query($sql);
     if (MDB2::isError($result)) {
         trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     return $mid;
 }
 /**
  * Check login data and set session vars and url forward  on success
  *
  * @param array $data
  */
 function perform($data)
 {
     $passwd = md5($data['passwd']);
     $sql = "SELECT \n                    uid,\n                    rights\n                FROM\n                    {$this->B->sys['db']['table_prefix']}user_users\n                WHERE\n                    login='******'login']}'\n                AND\n                    passwd='{$passwd}'\n                AND\n                    status=2";
     $result = $this->B->db->query($sql);
     if (MDB2::isError($result)) {
         trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     if ($result->numRows() == 1) {
         $row = $result->fetchRow(MDB2_FETCHMODE_ASSOC);
         $this->B->session->set('logged_id_user', $row['uid']);
         $this->B->session->set('logged_user_rights', $row['rights']);
         $admin = '';
         if (SF_SECTION == 'admin') {
             $admin = '?admin=1';
         }
         $query = '';
         if (isset($data['forward_urlvar'])) {
             $amp = '?';
             if (!empty($admin)) {
                 $amp = '&';
             }
             $query = $amp . base64_decode($data['forward_urlvar']);
         }
         @header('Location: ' . SF_BASE_LOCATION . '/index.php' . $admin . $query);
         exit;
     } else {
         return FAlSE;
     }
 }
예제 #8
0
function conectar()
{
    if (!isset($mdb2)) {
        //Local
        $db_name = 'root';
        $db_password = '';
        $db_server = 'localhost';
        $db_database = 'coopcrucial';
        //Nabica
        /*$db_name = 'coopcrucial';
          $db_password = '******';
          $db_server = 'coopcrucial.db.5840507.hostedresource.com';
          $db_database = 'coopcrucial';*/
        $dsn = 'mysql://' . $db_name . ':' . $db_password . '@' . $db_server . '/' . $db_database;
        try {
            $mdb2 =& MDB2::factory($dsn, true);
            if (MDB2::isError($mdb2)) {
                die($mdb2->getmessage() . ' - ' . $mdb2->getUserInfo());
            } else {
                $mdb2->setFetchMode(MDB2_FETCHMODE_ASSOC);
            }
            $mdb2 = array('mdb2' => $mdb2, 'dsn' => $dsn);
        } catch (Exception $exc) {
            echo $exc->getTraceAsString();
        }
    }
    return $mdb2;
}
예제 #9
0
 /**
  * add user
  *
  * @param array $data
  * @return int user id or false on error
  */
 function perform($data)
 {
     $this->B->{$data}['error'] = FALSE;
     $error =& $this->B->{$data}['error'];
     if ($this->login_exists($data['user_data']['login']) > 0) {
         $error = 'Login exists';
         return FALSE;
     }
     $uid = $this->B->db->nextId($this->B->sys['db']['table_prefix'] . 'user_users');
     if (MDB2::isError($uid)) {
         trigger_error($uid->getMessage() . "\n" . $uid->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         $error = 'Unexpected error';
         return FALSE;
     }
     $sql = '
         INSERT INTO 
             ' . $this->B->sys['db']['table_prefix'] . 'user_users
             (uid,forename,lastname,email,login,passwd,status,rights)
         VALUES
             (' . $uid . ',
              "' . $data['user_data']['forename'] . '",
              "' . $data['user_data']['lastname'] . '",
              "' . $data['user_data']['email'] . '",
              "' . $data['user_data']['login'] . '",
              "' . $data['user_data']['passwd'] . '",
              ' . $data['user_data']['status'] . ',
              ' . $data['user_data']['rights'] . ')';
     $res = $this->B->db->query($sql);
     if (MDB2::isError($res)) {
         trigger_error($res->getMessage() . "\n" . $res->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         $error = 'Unexpected error';
         return FALSE;
     }
     return $uid;
 }
 /**
  * add list data in db table
  *
  * @param array $data
  */
 function perform(&$data)
 {
     // get list messages attachment folder string
     $list_folder = commonUtil::unique_md5_str();
     if (!@mkdir(SF_BASE_DIR . '/data/earchive/' . $list_folder, SF_DIR_MODE)) {
         trigger_error("Cannot create list messages attachment folder! Contact the administrator.\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     $lid = $this->B->db->nextId($this->B->sys['db']['table_prefix'] . 'earchive_lists');
     if (MDB2::isError($lid)) {
         trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     $sql = '
         INSERT INTO 
             ' . $this->B->sys['db']['table_prefix'] . 'earchive_lists
             (lid,name,email,emailserver,description,folder,status)
         VALUES
             (' . $lid . ',
              "' . $data['name'] . '",
              "' . $data['email'] . '",
              "' . $data['emailserver'] . '",
              "' . $data['description'] . '",
              "' . $list_folder . '",
              ' . $data['status'] . ')';
     $result = $this->B->db->query($sql);
     if (MDB2::isError($result)) {
         trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     return TRUE;
 }
 /**
  * Assign array with message attachments data
  *
  * @param array $data
  */
 function perform(&$data)
 {
     if (empty($data['mid']) || empty($data['var'])) {
         trigger_error("'mid' or 'var' is empty!\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     // get var name to store the result
     $this->B->{$data}['var'] = array();
     $_result =& $this->B->{$data}['var'];
     $comma = '';
     foreach ($data['fields'] as $f) {
         $_fields .= $comma . $f;
         $comma = ',';
     }
     $sql = "\n            SELECT\n                {$_fields}\n            FROM\n                {$this->B->sys['db']['table_prefix']}earchive_attach\n            WHERE\n                mid={$data['mid']}            \n            ORDER BY\n                file ASC";
     $result = $this->B->db->query($sql);
     if (MDB2::isError($result)) {
         trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
     }
     $_result = array();
     if (is_object($result)) {
         while ($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) {
             $tmp = array();
             foreach ($data['fields'] as $f) {
                 $tmp[$f] = stripslashes($row[$f]);
             }
             $_result[] = $tmp;
         }
     }
     return TRUE;
 }
예제 #12
0
function dbConnect()
{
    global $db_type;
    global $db_user;
    global $db_pass;
    global $db_host;
    global $db_name;
    global $sql_regexp;
    if (!(isset($db_user) && $db_user != "")) {
        include_once "header.inc.php";
        error(ERR_DB_NO_DB_USER);
        include_once "footer.inc.php";
        exit;
    }
    if (!(isset($db_pass) && $db_pass != "")) {
        include_once "header.inc.php";
        error(ERR_DB_NO_DB_PASS);
        include_once "footer.inc.php";
        exit;
    }
    if (!(isset($db_host) && $db_host != "")) {
        include_once "header.inc.php";
        error(ERR_DB_NO_DB_HOST);
        include_once "footer.inc.php";
        exit;
    }
    if (!(isset($db_name) && $db_name != "")) {
        include_once "header.inc.php";
        error(ERR_DB_NO_DB_NAME);
        include_once "footer.inc.php";
        exit;
    }
    if (!isset($db_type) || !($db_type == "mysql" || $db_type == "pgsql")) {
        include_once "header.inc.php";
        error(ERR_DB_NO_DB_TYPE);
        include_once "footer.inc.php";
        exit;
    }
    $dsn = "{$db_type}://{$db_user}:{$db_pass}@{$db_host}/{$db_name}";
    $db = MDB2::connect($dsn);
    $db->setOption('portability', MDB2_PORTABILITY_ALL ^ MDB2_PORTABILITY_EMPTY_TO_NULL);
    if (MDB2::isError($db)) {
        // Error handling should be put.
        error(MYSQL_ERROR_FATAL, $db->getMessage());
    }
    // Do an ASSOC fetch. Gives us the ability to use ["id"] fields.
    $db->setFetchMode(MDB2_FETCHMODE_ASSOC);
    /* erase info */
    $mysql_pass = $dsn = '';
    // Add support for regular expressions in both MySQL and PostgreSQL
    if ($db_type == "mysql") {
        $sql_regexp = "REGEXP";
    } elseif ($db_type == "pgsql") {
        $sql_regexp = "~";
    } else {
        error(ERR_DB_NO_DB_TYPE);
    }
    return $db;
}
 /**
  * Check if version number has changed and perfom additional upgarde code
  * Furthermore assign array with module menu names for the top right
  * module html seletor
  *
  * @param array $data
  */
 function perform($data)
 {
     // get os related separator to set include path
     if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
         $tmp_separator = ';';
     } else {
         $tmp_separator = ':';
     }
     // set include path to the PEAR packages
     ini_set('include_path', SF_BASE_DIR . 'modules/common/PEAR' . $tmp_separator . ini_get('include_path'));
     unset($tmp_separator);
     // include PEAR DB class
     include_once SF_BASE_DIR . 'modules/common/PEAR/MDB2.php';
     // init system config array
     $this->B->sys = array();
     // include system config array $this->B->sys
     if (file_exists(SF_BASE_DIR . 'modules/common/config/config.php')) {
         include_once SF_BASE_DIR . 'modules/common/config/config.php';
     }
     // if setup was done
     if ($this->B->sys['info']['status'] == TRUE) {
         $this->B->dsn = array('phptype' => $this->B->sys['db']['type'], 'username' => $this->B->sys['db']['user'], 'password' => $this->B->sys['db']['passwd'], 'hostspec' => $this->B->sys['db']['host'], 'database' => $this->B->sys['db']['name']);
         $this->B->db =& MDB2::connect($this->B->dsn);
         if (MDB2::isError($this->B->db)) {
             trigger_error('Cannot connect to the database: ' . __FILE__ . ' ' . __LINE__, E_USER_ERROR);
         }
     } else {
         // switch to the admin section if we comes from the public section
         if (SF_SECTION == 'public') {
             @header('Location: ' . SF_BASE_LOCATION . '/index.php?admin=1');
             exit;
         }
         // launch setup screen
         include $this->B->M(MOD_COMMON, 'get_module_view', array('m' => 'setup', 'view' => 'index'));
         // Send the output buffer to the client
         ob_end_flush();
         exit;
     }
     // Check for upgrade
     if (MOD_COMMON_VERSION != (string) $this->B->sys['module']['common']['version']) {
         // set the new version num of this module
         $this->B->sys['module']['common']['version'] = MOD_COMMON_VERSION;
         $this->B->system_update_flag = TRUE;
         // include here additional upgrade code
     }
     if (SF_SECTION == 'admin') {
         // sort handler array by name
         ksort($this->B->handler_list);
         // assign template handler names array
         // this array is used to build the modul select form of the admin menu
         $this->B->tpl_mod_list = array();
         foreach ($this->B->handler_list as $key => $value) {
             if ($value['menu_visibility'] == TRUE) {
                 $this->B->tpl_mod_list[$key] = $value;
             }
         }
     }
 }
예제 #14
0
function connectDB()
{
    global $_CONF;
    $objConnID =& MDB2::factory($_CONF['db']['dsn']);
    if (MDB2::isError($objConnID)) {
        throw new Exception('Database connection failed: ' . $objConnID->getMessage(), SQL_CONN_ERROR);
    }
    return $objConnID;
}
예제 #15
0
 public function getDBVersion()
 {
     $query = 'SELECT * FROM v$version';
     $res = $this->db->query($query);
     if (MDB2::isError($res)) {
         return parent::getDBVersion();
     }
     $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
     return isset($row['banner']) ? $row['banner'] : parent::getDBVersion();
 }
예제 #16
0
 public function tearDown()
 {
     if (!$this->db || MDB2::isError($this->db)) {
         return;
     }
     if ($this->tableExists($this->table)) {
         $this->db->manager->dropTable($this->table);
     }
     parent::tearDown();
 }
예제 #17
0
function &s_db_slink()
{
    $dsn = array('phptype' => "mysql", 'username' => $_SERVER['SINASRV_DB4_USER_R'], 'password' => $_SERVER['SINASRV_DB4_PASS_R'], 'hostspec' => $_SERVER['SINASRV_DB4_HOST_R'], 'port' => $_SERVER['SINASRV_DB4_PORT_R'], 'database' => $_SERVER['SINASRV_DB4_NAME_R'], 'charset' => 'utf8');
    $db = MDB2::connect($dsn);
    if (MDB2::isError($db)) {
        die(s_error($db->getMessage()));
    }
    $db->setFetchMode(MDB2_FETCHMODE_ASSOC);
    return $db;
}
예제 #18
0
 /**
  * Execute a stored procedure and return any results
  *
  * @param string $name string that identifies the function to execute
  * @param mixed  $params  array that contains the paramaters to pass the stored proc
  * @param mixed   $types  array that contains the types of the columns in
  *                        the result set
  * @param mixed $result_class string which specifies which result class to use
  * @param mixed $result_wrap_class string which specifies which class to wrap results in
  * @return mixed a result handle or MDB2_OK on success, a MDB2 error on failure
  * @access public
  */
 function executeStoredProc($name, $params = null, $types = null, $result_class = true, $result_wrap_class = false)
 {
     $db = $this->getDBInstance();
     if (MDB2::isError($db)) {
         return $db;
     }
     $query = 'CALL ' . $name;
     $query .= $params ? '(' . implode(', ', $params) . ')' : '()';
     return $db->query($query, $types, $result_class, $result_wrap_class);
 }
예제 #19
0
 function fetch($con, $situacao_id)
 {
     $sql = "SELECT * FROM situacao WHERE situacao_id = " . $situacao_id;
     $qry = $con->query($sql);
     if (!MDB2::isError($qry)) {
         $row = $qry->fetchRow(MDB2_FETCHMODE_ASSOC);
         $this->situacao_id = $row['situacao_id'];
         $this->descricao = $row['descricao'];
     }
 }
예제 #20
0
 function DB()
 {
     $dsn = base_application_registry::getDSN();
     $this->ensure($dsn, "No DSN");
     if (!$this->db) {
         $this->db = MDB2::connect($dsn);
     }
     $this->ensure(!MDB2::isError($this->db), "Unable to connect to DB");
     return $this->db;
 }
예제 #21
0
 function dbconnect()
 {
     // データベースに接続
     $this->_db = MDB2::factory($this->sqltype . '://' . $this->user . ':' . $this->password . '@' . $this->server . '/' . $this->dbname . '?charset=utf8');
     // 接続チェック
     if (MDB2::isError($this->_db)) {
         return $this->dbreturn(FALSE, $this->_db->getMessage());
     }
     //カラム名でのアクセスに指定
     $this->_db->setFetchMode(MDB2_FETCHMODE_ASSOC);
 }
예제 #22
0
파일: rollback.php 프로젝트: stof/pearweb
 protected function queryChange($sql)
 {
     $affected = $this->mdb2->exec($sql);
     if (MDB2::isError($affected)) {
         throw new RuntimeException("DB error occurred: " . $affected->getDebugInfo());
     }
     if ($affected < 1) {
         throw new UnexpectedValueException("No rows affected. Invalid proposal ID?");
     }
     return true;
 }
 function _create_tables()
 {
     $table = $this->B->conf_val['db']['table_prefix'] . 'bad_words';
     $fields = array('word' => array('type' => 'text', 'length' => 255), 'lang' => array('type' => 'text', 'length' => 4));
     $result = $this->B->dbmanager->createTable($table, $fields);
     if (MDB2::isError($result)) {
         trigger_error($result->getMessage() . "\n" . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         $this->B->setup_error[] = $result->getMessage() . "\n" . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__;
         return FALSE;
     }
     return TRUE;
 }
예제 #24
0
 function DBConnection()
 {
     $this->AbstractBaseComponent();
     // Prepared dsn for connection
     $dsn = $this->db_type . '://' . $this->db_user . ':' . $this->db_pass . '@' . $this->db_host . '/' . $this->db_name;
     $options = array('debug' => 2, 'portability' => MDB2_PORTABILITY_ALL);
     // !!! $this->dbh using for all db connection.
     $this->dbh =& MDB2::factory($dsn, $options);
     if (MDB2::isError($this->dbh)) {
         echo $this->dbh->getMessage() . ' - ' . $this->dbh->getUserinfo();
     }
 }
 /**
  * delete user
  *
  * @param array $data
  * @return bool true or false on error
  */
 function perform($data)
 {
     $this->B->{$data}['error'] = FALSE;
     $error =& $this->B->{$data}['error'];
     $sql = "\n            DELETE FROM \n                {$this->B->sys['db']['table_prefix']}user_users\n            WHERE\n                uid={$data['user_id']}";
     $result = $this->B->db->query($sql);
     if (MDB2::isError($result)) {
         trigger_error($result->getMessage() . "\n" . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         $error = 'Unexpected error';
         return FALSE;
     }
     return TRUE;
 }
예제 #26
0
 function insere($con, $vol_id)
 {
     $sql = "INSERT INTO lacres VALUES (NULL";
     $sql .= ", " . $con->quote($vol_id);
     $sql .= ", " . $con->quote($this->nLacre);
     $sql .= ")";
     $qry = $con->query($sql);
     if (MDB2::isError($qry)) {
         set_error('Erro lacres: ' . $qry->getMessage());
         return false;
     } else {
         $lacres_id = $con->lastInsertID("lacres", "lacres_id");
     }
 }
예제 #27
0
 /**
  * Create
  *
  * @param array $values
  *
  * @return array
  * @throws Panda_Exception
  * @required name 名前
  * @required age  年齢
  */
 public function onCreate($values)
 {
     $extended = $this->_db->extended;
     /** @param $extended MDB2_Extended */
     $values['created_at'] = _BEAR_DATETIME;
     //現在時刻
     $result = $extended->autoExecute($this->_table, $values, MDB2_AUTOQUERY_INSERT);
     if (MDB2::isError($result, MDB2_ERROR_CONSTRAINT)) {
         throw new Panda_Exception('IDが重複しています', 409);
     } elseif (MDB2::isError($result)) {
         throw new Panda_Exception('登録できませんでした', 500);
     }
     return $result;
 }
예제 #28
0
 function insere($con, $det_id)
 {
     $sql = "INSERT INTO infAdProd VALUES (NULL";
     $sql .= ", " . $con->quote($det_id);
     $sql .= ", " . $con->quote($this->infAdProd);
     $sql .= ")";
     $qry = $con->query($sql);
     if (MDB2::isError($qry)) {
         set_error('Erro infAdProd: ' . $qry->getMessage());
         return false;
     } else {
         $infAdProd_id = $con->lastInsertID("infAdProd", "infAdProd_id");
     }
 }
 /**
  * get all messages
  *
  * @param array $fields Field names of the list db table
  * @return array Lists data 
  */
 function &_get_all_messages($fields)
 {
     $comma = '';
     foreach ($fields as $f) {
         $_fields .= $comma . $f;
         $comma = ',';
     }
     $sql = "\n            SELECT\n                {$_fields}\n            FROM\n                {$this->B->sys['db']['table_prefix']}earchive_messages";
     $result = $this->B->db->query($sql);
     if (MDB2::isError($result)) {
         trigger_error($result->getMessage() . "\n\nINFO: " . $result->userinfo . "\n\nFILE: " . __FILE__ . "\nLINE: " . __LINE__, E_USER_ERROR);
         return FALSE;
     }
     return $result;
 }
예제 #30
0
 function insere($con, $infNFe_id)
 {
     $sql = "INSERT INTO exporta VALUES (NULL";
     $sql .= ", " . $con->quote($infNFe_id);
     $sql .= ", " . $con->quote($this->UFEmbarq);
     $sql .= ", " . $con->quote($this->xLocEmbarq);
     $sql .= ")";
     $qry = $con->query($sql);
     if (MDB2::isError($qry)) {
         set_error('Erro exporta: ' . $qry->getMessage());
         return false;
     } else {
         $exporta_id = $con->lastInsertID("exporta", "exporta_id");
     }
 }