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


PHP db_errno函数代码示例

本文整理汇总了PHP中db_errno函数的典型用法代码示例。如果您正苦于以下问题:PHP db_errno函数的具体用法?PHP db_errno怎么用?PHP db_errno使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: api_mycss

function api_mycss()
{
    $sql = "SELECT `css` FROM `css` WHERE `uid` = '" . intval(uid()) . "' LIMIT 1";
    $data = get_var($sql);
    if (db_errno() != 0) {
        apiController::send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . db_error());
    }
    return apiController::send_result($data);
}
开发者ID:ramo01,项目名称:1kapp,代码行数:9,代码来源:app.php

示例2: db_query

function db_query($query, $database = "", $conn = "")
{
    global $cfg;
    if ($conn) {
        /* connection is provided*/
        $response = $database ? mysql_db_query($database, $query, $conn) : mysql_query($query, $conn);
    } else {
        $response = $database ? mysql_db_query($database, $query) : mysql_query($query);
    }
    if (!$response) {
        //error reporting
        $alert = '[' . $query . ']' . "\n\n" . db_error();
        Sys::log(LOG_ALERT, 'DB Error #' . db_errno(), $alert, $cfg && $cfg->alertONSQLError());
        //echo $msg; #uncomment during debuging or dev.
    }
    return $response;
}
开发者ID:kumarsivarajan,项目名称:ctrl-dock,代码行数:17,代码来源:mysql.php

示例3: db_init

function db_init()
{
    $password = substr(md5(time() . rand(1, 9999)), rand(1, 20), 12);
    $sql_contents = preg_replace("/(#.+[\r|\n]*)/", '', file_get_contents(AROOT . 'misc' . DS . 'install.sql'));
    // 更换变量
    $sql_contents = str_replace('{password}', md5($password), $sql_contents);
    $sqls = split_sql_file($sql_contents);
    foreach ($sqls as $sql) {
        run_sql($sql);
    }
    if (db_errno() == 0) {
        info_page('数据库初始化成功,请使用【member@teamtoy.net】和【' . $password . '】<a href="/" target="new">登入并添加用户</a>');
        exit;
    } else {
        info_page(db_error());
        exit;
    }
}
开发者ID:ramo01,项目名称:1kapp,代码行数:18,代码来源:app.function.php

示例4: db_init

function db_init()
{
    $password = substr(md5(time() . rand(1, 9999)), rand(1, 20), 12);
    $sql_contents = preg_replace("/(#.+[\r|\n]*)/", '', file_get_contents(AROOT . 'misc' . DS . 'install.sql'));
    // 更换变量
    $sql_contents = str_replace('{password}', md5($password), $sql_contents);
    $sqls = split_sql_file($sql_contents);
    foreach ($sqls as $sql) {
        run_sql($sql);
    }
    if (db_errno() == 0) {
        info_page(__('DATABASE_INIT_FINISHED', $password));
        exit;
    } else {
        info_page(db_error());
        exit;
    }
}
开发者ID:xianliflc,项目名称:teamirr,代码行数:18,代码来源:app.function.php

示例5: turn

 function turn()
 {
     if (!is_admin()) {
         return render(array('code' => LR_API_FORBIDDEN, 'message' => __('API_MESSAGE_ONLY_ADMIN')), 'rest');
     }
     $on = intval(v('on'));
     $folder_name = z(t(v('folder_name')));
     if (strlen($folder_name) < 1) {
         return render(array('code' => LR_API_ARGS_ERROR, 'message' => 'FOLDER NAME CANNOT BE EMPTY'), 'rest');
     }
     $sql = "REPLACE `plugin` (`folder_name` , `on`) VALUES ( '" . s($folder_name) . "' , '" . intval($on) . "' )";
     run_sql($sql);
     if (db_errno() == 0) {
         return render(array('code' => 0, 'message' => 'ok'), 'rest');
     } else {
         return render(array('code' => LR_API_DB_ERROR, 'message' => db_error()), 'rest');
     }
 }
开发者ID:xianliflc,项目名称:teamirr,代码行数:18,代码来源:pluglist.class.php

示例6: plugin_simple_token

function plugin_simple_token()
{
    $do = z(t(v('do')));
    switch ($do) {
        case 'create':
        case 'refresh':
            $new_token = substr(md5(uid() . time("Y h j G") . rand(1, 9999)), 0, rand(9, 20));
            $new_token = uid() . substr(md5($new_token), 0, 10);
            $sql = "REPLACE INTO `stoken` ( `uid` , `token` , `on` ) VALUES ( '" . intval(uid()) . "' , '" . s($new_token) . "' , '1' )";
            run_sql($sql);
            if (db_errno() == 0) {
                return ajax_echo('done');
            } else {
                return ajax_echo('error');
            }
            break;
        case 'close':
            $sql = "UPDATE `stoken` SET `on` = '0' WHERE `uid` = '" . intval(uid()) . "' LIMIT 1";
            run_sql($sql);
            if (db_errno() == 0) {
                return ajax_echo('done');
            } else {
                return ajax_echo('error');
            }
            break;
        case 'reopen':
            $sql = "UPDATE `stoken` SET `on` = '1' WHERE `uid` = '" . intval(uid()) . "' LIMIT 1";
            run_sql($sql);
            if (db_errno() == 0) {
                return ajax_echo('done');
            } else {
                return ajax_echo('error');
            }
            break;
        default:
            $data['tinfo'] = get_line("SELECT * FROM `stoken` WHERE `uid` = '" . intval(uid()) . "' LIMIT 1");
            render($data, 'ajax', 'plugin', 'simple_token');
    }
}
开发者ID:ramo01,项目名称:1kapp,代码行数:39,代码来源:app.php

示例7: db_query

                $checkin_date = "'" . $_POST["checkin_date"] . "'";
                $checkout_date = !empty($_POST["checkout_date"]) ? "'" . $_POST["checkout_date"] . "'" : 'NULL';
                $residence_id = $_POST["residence_id"];
                $payment_mode = $_POST["payment_mode"];
                $agents_ac_no = !empty($_POST["agents_ac_no"]) ? $_POST["agents_ac_no"] : 'NULL';
                $roomid = $_POST["roomid"];
                $checkedin_by = 1;
                //$_POST["checkedin_by"];
                $invoice_no = !empty($_POST["invoice_no"]) ? $_POST["invoice_no"] : 'NULL';
                $results = db_query('
					INSERT INTO booking (guestid, booking_type, meal_plan, no_adults, no_child, checkin_date, checkout_date,
						residence_id, payment_mode, agents_ac_no, roomid, checkedin_by, invoice_no, billed)
					VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0)', array($guestid, $booking_type, $meal_plan, $no_adults, $no_child, $checkin_date, $checkout_date, $residence_id, $payment_mode, $agents_ac_no, $roomid, $checkedin_by, $invoice_no));
                if (!$results || $results->rowCount() == 0) {
                    //should log mysql errors to a file instead of displaying them to the user
                    echo 'Invalid query: ' . db_errno() . "<br>" . ": " . db_error() . "<br>";
                    echo "Guests NOT BOOKED.";
                    //return;
                } else {
                    echo "<div align=\"center\"><h1>Guests successful checked in.</h1></div>";
                    //create bill - let user creat bill/create bill automatically
                    $results = db_query('INSERT INTO bills (book_id, billno, date_billed) SELECT booking.book_id, booking.book_id, booking.checkin_date FROM booking WHERE booking.billed = 0');
                    $msg[0] = "Sorry no bill created";
                    $msg[1] = "Bill successfull created";
                    AddSuccess($results, $msg);
                    //if bill succesful created update billed to 1 in bookings- todo
                    //get the actual updated book_id, currently this simply updates all bookings
                    $results = db_query('UPDATE booking SET billed = 1 WHERE billed = 0');
                    $msg[0] = "Sorry Booking not updated";
                    $msg[1] = "Booking successful updated";
                    AddSuccess($results, $msg);
开发者ID:bogiesoft,项目名称:hotelmis,代码行数:31,代码来源:bookings.php

示例8: runQuery

function runQuery($query, $function, $label)
{
    global $dbh;
    if (!($result = db_query($query, $dbh))) {
        // query execution failed, set the log and status:
        setLogAndStatus($query, db_errno($dbh), db_error($dbh), $function, $label);
        return 0;
    } else {
        return $result;
    }
}
开发者ID:kktsvetkov,项目名称:1double.com,代码行数:11,代码来源:shared.inc.php

示例9: plugin_check_mail

function plugin_check_mail()
{
    if (intval(kget('mqueue_on')) != 1) {
        return false;
    }
    $sql = "SELECT * FROM `mail_queue` WHERE `timeline` > '" . date("Y-m-d H:i:s", strtotime("-1 hour")) . "' LIMIT 1";
    if ($line = get_line($sql)) {
        session_write_close();
        $info = unserialize($line['data']);
        if (phpmailer_send_mail($info['to'], $info['subject'], $info['body'], kget('mqueue_username'), kget('mqueue_server'), kget('mqueue_port'), kget('mqueue_username'), kget('mqueue_password'))) {
            $sql = "DELETE FROM `mail_queue` WHERE `id` = '" . intval($line['id']) . "' LIMIT 1";
        } else {
            $sql = "UPDATE `mail_queue` SET `timeline` = '" . date("Y-m-d H:i:s", strtotime("-2 hours")) . "' LIMIT 1 ";
        }
        run_sql($sql);
    }
    include_once AROOT . 'controller' . DS . 'api.class.php';
    if (db_errno() != 0) {
        apiController::send_error(LR_API_DB_ERROR, 'DATABASE ERROR ' . db_error());
    }
    return apiController::send_result(array('to_send' => get_var("SELECT COUNT(*) FROM `mail_queue` WHERE `timeline` > '" . date("Y-m-d H:i:s", strtotime("-1 hour")) . "' ")));
}
开发者ID:xianliflc,项目名称:teamirr,代码行数:22,代码来源:app.php

示例10: sql

function sql($statment, &$o)
{
    /*
    	Supported options that can be passed in $o options array (as array keys):
    	'silentErrors': If true, errors will be returned in $o['error'] rather than displaying them on screen and exiting.
    */
    global $Translation;
    static $connected = false, $db_link;
    $dbServer = config('dbServer');
    $dbUsername = config('dbUsername');
    $dbPassword = config('dbPassword');
    $dbDatabase = config('dbDatabase');
    ob_start();
    if (!$connected) {
        /****** Connect to MySQL ******/
        if (!extension_loaded('mysql') && !extension_loaded('mysqli')) {
            echo error_message('PHP is not configured to connect to MySQL on this machine. Please see <a href="http://www.php.net/manual/en/ref.mysql.php">this page</a> for help on how to configure MySQL.');
            $e = ob_get_contents();
            ob_end_clean();
            if ($o['silentErrors']) {
                $o['error'] = $e;
                return FALSE;
            } else {
                echo $e;
                exit;
            }
        }
        if (!($db_link = @db_connect($dbServer, $dbUsername, $dbPassword))) {
            echo error_message(db_error($db_link, true));
            $e = ob_get_contents();
            ob_end_clean();
            if ($o['silentErrors']) {
                $o['error'] = $e;
                return FALSE;
            } else {
                echo $e;
                exit;
            }
        }
        /****** Select DB ********/
        if (!db_select_db($dbDatabase, $db_link)) {
            echo error_message(db_error($db_link));
            $e = ob_get_contents();
            ob_end_clean();
            if ($o['silentErrors']) {
                $o['error'] = $e;
                return FALSE;
            } else {
                echo $e;
                exit;
            }
        }
        $connected = true;
    }
    if (!($result = @db_query($statment, $db_link))) {
        if (!stristr($statment, "show columns")) {
            // retrieve error codes
            $errorNum = db_errno($db_link);
            $errorMsg = db_error($db_link);
            echo error_message(htmlspecialchars($errorMsg) . "\n\n<!--\n" . $Translation['query:'] . "\n {$statment}\n-->\n\n");
            $e = ob_get_contents();
            ob_end_clean();
            if ($o['silentErrors']) {
                $o['error'] = $errorMsg;
                return false;
            } else {
                echo $e;
                exit;
            }
        }
    }
    ob_end_clean();
    return $result;
}
开发者ID:WebxOne,项目名称:fwldba,代码行数:74,代码来源:incCommon.php

示例11: upload

 function upload($files, $inline = false)
 {
     $i = array();
     if (!is_array($files)) {
         $files = array($files);
     }
     foreach ($files as $file) {
         if (($fileId = is_numeric($file) ? $file : AttachmentFile::upload($file)) && is_numeric($fileId)) {
             $sql = 'INSERT INTO ' . ATTACHMENT_TABLE . ' SET `type`=' . db_input($this->getType()) . ',object_id=' . db_input($this->getId()) . ',file_id=' . db_input($fileId) . ',inline=' . db_input($inline ? 1 : 0);
             // File may already be associated with the draft (in the
             // event it was deleted and re-added)
             if (db_query($sql, function ($errno) {
                 return $errno != 1062;
             }) || db_errno() == 1062) {
                 $i[] = $fileId;
             }
         }
     }
     return $i;
 }
开发者ID:ed00m,项目名称:osTicket-1.8,代码行数:20,代码来源:class.attachment.php

示例12: db_prepare

function db_prepare($stmt)
{
    global $ost, $__db;
    $res = $__db->prepare($stmt);
    if (!$res && $ost) {
        // Include a backtrace in the error email
        $msg = '[' . $stmt . "]\n\n" . db_error();
        $ost->logDBError('DB Error #' . db_errno(), $msg);
    }
    return $res;
}
开发者ID:dmiguel92,项目名称:osTicket-1.8,代码行数:11,代码来源:mysqli.php

示例13: db_query

function db_query($query, $database = "", $conn = "")
{
    global $ost;
    if ($conn) {
        /* connection is provided*/
        $res = $database ? mysql_db_query($database, $query, $conn) : mysql_query($query, $conn);
    } else {
        $res = $database ? mysql_db_query($database, $query) : mysql_query($query);
    }
    if (!$res && $ost) {
        //error reporting
        $msg = '[' . $query . ']' . "\n\n" . db_error();
        $ost->logDBError('DB Error #' . db_errno(), $msg);
        //echo $msg; #uncomment during debuging or dev.
    }
    return $res;
}
开发者ID:nunomartins,项目名称:osTicket-1.7,代码行数:17,代码来源:mysql.php

示例14: setBackup


//.........这里部分代码省略.........
    reset($PARAM);
    //delete backups
    if ($PARAM['delete'] == 1) {
        if (count($BACKUPS) == 0) {
            $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20008";
            printPage('_admin_done.htmlt');
            return;
        }
        for ($i = 0; $i < count($BACKUPS); $i++) {
            if (!@unlink($BCKUPS[$BACKUPS[$i]])) {
                setLogAndStatus("Deleting", $BCKUPS[$BACKUPS[$i]], "setBackup()", 'DEL_BACKUP');
            }
        }
        $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20054";
        printPage('_admin_done.htmlt');
        return;
    }
    //import database backup
    if ($PARAM['import'] == 1) {
        if (count($BACKUPS) > 1) {
            $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20053";
            printPage('_admin_done.htmlt');
            return;
        }
        if (count($BACKUPS) == 0) {
            $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20008";
            printPage('_admin_done.htmlt');
            return;
        }
        //get backup file
        $file = fread(fopen($BCKUPS[$BACKUPS[0]], 'r'), filesize($BCKUPS[$BACKUPS[0]]));
        ////---- [Mrasnika's] Edition 21.03.2002
        split_sql_file($BACKUP, $file);
        //reset tables
        if (!($res = db_list_tables($dbname, $dbh))) {
            setLogAndStatus("db_list_tables()", 1, $dbname, "databaseBackup()", 'LIST_TABLES_2');
        }
        $num_tables = db_num_rows($res);
        $i = 0;
        while ($i < $num_tables) {
            $table = db_tablename($res, $i);
            $query = "DELETE FROM {$dbname}.{$table}";
            $result = runQuery($query, 'setBackup()', 'RESET_TABLES');
            $i++;
        }
        //fill tables
        while (list($k, $query) = each($BACKUP)) {
            if (!ereg('^#', $query)) {
                if (!($result = db_query($query, $dbh))) {
                    setLogAndStatus($query, db_errno($dbh), db_error($dbh), "databaseBackup()", 'RESTORE_DB');
                    $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20055";
                    printPage('_admin_done.htmlt');
                    return;
                }
            }
        }
        $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20056";
        printPage('_admin_done.htmlt');
        return;
    }
    $backups = opendir(getAdmSetting('BACKUP_DIR'));
    $last = 0;
    while (($file = readdir($backups)) != false) {
        if (!is_dir($file)) {
            $date = stat(getAdmSetting('BACKUP_DIR') . "/{$file}");
            if ($last < $date[9]) {
                $month = intval(date('m'));
                $SUBS['LAST'] = $MSG[20051] . date(' d ', $date[9]) . $MONTHS[$month] . date(' Y H.i.s', $date[9]);
            }
            $SUBS['SIZE'] = sprintf('%0.2f KB', $date[7] / 1024);
            $SUBS['NAME'] = eregi_replace('_', ':', $file);
            $SUBS['CHECK'] = eregi_replace('[^a-z0-9]', '_', $file);
            //checkbox name
            $SUBS['WHERE'] = getAdmSetting('BACKUP_DIR') . "/{$file}";
            if (!($BACKUP = @file(getAdmSetting('BACKUP_DIR') . "/{$file}"))) {
                setLogAndStatus("Reading", 0, getAdmSetting('BACKUP_DIR') . "/{$file}", "setBackup()", 'READ_FILE');
            }
            $comments = '';
            //get comments from the beginning of the file
            for ($i = 0; $i < count($BACKUP); $i++) {
                if (eregi('^##(.*)$', $BACKUP[$i], $R)) {
                    $comments .= $R[1];
                }
            }
            if ($comments != '') {
                $SUBS['COMMENTS'] = ' &nbsp; ' . ereg_replace("\n", '<BR> &nbsp; ', htmlEncode($comments));
                $SUBS['COMMENTS'] = ereg_replace('<BR> &nbsp; $', '', $SUBS['COMMENTS']);
            } else {
                $SUBS['COMMENTS'] = '';
            }
            $SUBS['BACKUPS'] .= fileParse('_admin_backup_row.htmlt');
        }
    }
    closedir($backups);
    if ($PARAM['err'] != '') {
        $SUBS['ERROR'] = $MSG[$PARAM['err']];
        $SUBS['BACKUP_ERROR'] = fileParse('_admin_error.htmlt');
    }
    printPage('_admin_backup.htmlt');
}
开发者ID:kktsvetkov,项目名称:1double.com,代码行数:101,代码来源:admin.php

示例15: elseif

             if (!$res or !($replyID = db_insert_id())) {
                 $errors['err'] = 'Unable to create the reply. Internal error';
             } else {
                 $msg = 'Premade reply created';
             }
         } elseif ($_POST['a'] == 'update') {
             //update
             $res = db_query('UPDATE ' . KB_PREMADE_TABLE . ' ' . $sql . ' WHERE premade_id=' . db_input($_POST['id']));
             if ($res && db_affected_rows()) {
                 $msg = 'Premade reply updated';
                 $answer = db_fetch_array(db_query('SELECT * FROM ' . KB_PREMADE_TABLE . ' WHERE premade_id=' . db_input($id)));
             } else {
                 $errors['err'] = 'Internal update error occured. Try again';
             }
         }
         if ($errors['err'] && db_errno() == 1062) {
             $errors['title'] = 'Title already exists!';
         }
     } else {
         $errors['err'] = $errors['err'] ? $errors['err'] : 'Error(s) occured. Try again';
     }
     break;
 case 'process':
     if (!$_POST['canned'] || !is_array($_POST['canned'])) {
         $errors['err'] = 'You must select at least one item';
     } else {
         $msg = '';
         $ids = implode(',', $_POST['canned']);
         $selected = count($_POST['canned']);
         if (isset($_POST['enable'])) {
             if (db_query('UPDATE ' . KB_PREMADE_TABLE . ' SET isenabled=1,updated=NOW() WHERE isenabled=0 AND premade_id IN(' . $ids . ')')) {
开发者ID:kumarsivarajan,项目名称:ctrl-dock,代码行数:31,代码来源:kb.php


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