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


PHP db_start函数代码示例

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


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

示例1: DBQuery

function DBQuery($sql)
{
    global $DatabaseType, $_CENTRE;
    $connection = db_start();
    switch ($DatabaseType) {
        case 'oracle':
            $result = @ociparse($connection, $sql);
            if ($result === false) {
                $errors = OCIError($connection);
                db_show_error($sql, "DB Parse Failed.", $errors['message']);
            }
            if (!@OciExecute($result)) {
                $errors = OCIError($result);
                db_show_error($sql, "DB Execute Failed.", $errors['message']);
            }
            OciCommit($connection);
            OciLogoff($connection);
            break;
        case 'postgres':
            $sql = ereg_replace("([,\\(=])[\r\n\t ]*''", '\\1NULL', $sql);
            $result = @pg_exec($connection, $sql);
            if ($result === false) {
                echo $sql;
                $errstring = pg_last_error($connection);
                db_show_error($sql, "DB Execute Failed.", $errstring);
            }
            break;
        case 'mysql':
            $sql = ereg_replace("([,\\(=])[\r\n\t ]*''", '\\1NULL', $sql);
            if (preg_match_all("/'(\\d\\d-[A-Za-z]{3}-\\d{2,4})'/", $sql, $matches)) {
                foreach ($matches[1] as $match) {
                    $dt = date('Y-m-d', strtotime($match));
                    $sql = preg_replace("/'{$match}'/", "'{$dt}'", $sql);
                }
            }
            if (substr($sql, 0, 6) == "BEGIN;") {
                $array = explode(";", $sql);
                foreach ($array as $value) {
                    if ($value != "") {
                        $result = mysql_query($value);
                        if (!$result) {
                            mysql_query("ROLLBACK");
                            die(db_show_error($sql, "DB Execute Failed.", mysql_error()));
                        }
                    }
                }
            } else {
                $result = mysql_query($sql) or die(db_show_error($sql, "DB Execute Failed.", mysql_error()));
            }
            break;
    }
    return $result;
}
开发者ID:SoftScape,项目名称:opensis,代码行数:53,代码来源:database.inc.php

示例2: DBQuery

function DBQuery($sql)
{
    $connection = db_start();
    // TRANSLATION: do NOT translate these since error messages need to stay in English for technical support
    $sql = preg_replace("/([,\\(=])[\r\n\t ]*''[\r\n\t]*(?!')/", '\\1NULL', $sql);
    $result = @pg_exec($connection, $sql);
    if ($result === false) {
        $errstring = pg_last_error($connection);
        db_show_error($sql, "DB Execute Failed.", $errstring);
    }
    return $result;
}
开发者ID:fabioassuncao,项目名称:rosariosis,代码行数:12,代码来源:database.inc.php

示例3: load_libraries

function load_libraries()
{
    $libs = array('error', 'module', 'security', 'url', 'asset', 'session');
    $libs = array_unique(array_merge($libs, get_config('autoload', array())));
    $conn = get_config('database')->load;
    foreach ($libs as $lib) {
        if (load_library($lib)) {
            if ($lib == 'database' && $conn) {
                db_start();
            }
        }
    }
}
开发者ID:londomloto,项目名称:immortal,代码行数:13,代码来源:cores.php

示例4: DBQuery

function DBQuery($sql)
{
    global $DatabaseType;
    $connection = db_start();
    switch ($DatabaseType) {
        case 'oracle':
            $result = @ociparse($connection, $sql);
            // TRANSLATION: do NOT translate these since error messages need to stay in English for technical support
            if ($result === false) {
                $errors = OCIError($connection);
                db_show_error($sql, "DB Parse Failed.", $errors['message']);
            }
            if (!@OciExecute($result)) {
                $errors = OCIError($result);
                db_show_error($sql, "DB Execute Failed.", $errors['message']);
            }
            OciCommit($connection);
            OciLogoff($connection);
            break;
        case 'postgres':
            // TRANSLATION: do NOT translate these since error messages need to stay in English for technical support
            $sql = preg_replace("/([,\\(=])[\r\n\t ]*''/", '\\1NULL', $sql);
            $result = @pg_exec($connection, $sql);
            if ($result === false) {
                $errstring = pg_last_error($connection);
                db_show_error($sql, "DB Execute Failed.", $errstring);
            }
            break;
        case 'mysql':
            // TRANSLATION: do NOT translate these since error messages need to stay in English for technical support
            mysql_query("SET SESSION TRANSACTION ISOLATION LEVEL SERIALIZABLE");
            mysql_query("SET SESSION SQL_MODE='ANSI'");
            $sql = preg_replace("/([,\\(=])[\r\n\t ]*''/", '\\1NULL', $sql);
            $result = mysql_query($sql);
            if ($result === false) {
                $errstring = mysql_error();
                db_show_error($sql, "DB Execute Failed.", $errstring);
            }
            break;
    }
    return $result;
}
开发者ID:linil,项目名称:centreSIS,代码行数:42,代码来源:database.inc.php

示例5: DBQuery

function DBQuery($sql)
{
    global $DatabaseType, $_openSIS;
    $connection = db_start();
    switch ($DatabaseType) {
        case 'mysql':
            $sql = str_replace('&', "", $sql);
            $sql = str_replace('&quot', "", $sql);
            $sql = str_replace(''', "", $sql);
            $sql = str_replace('<', "", $sql);
            $sql = str_replace('>', "", $sql);
            $sql = ereg_replace("([,\\(=])[\r\n\t ]*''", '\\1NULL', $sql);
            if (preg_match_all("/'(\\d\\d-[A-Za-z]{3}-\\d{2,4})'/", $sql, $matches)) {
                foreach ($matches[1] as $match) {
                    $dt = date('Y-m-d', strtotime($match));
                    $sql = preg_replace("/'{$match}'/", "'{$dt}'", $sql);
                }
            }
            if (substr($sql, 0, 6) == "BEGIN;") {
                $array = explode(";", $sql);
                foreach ($array as $value) {
                    if ($value != "") {
                        $result = mysql_query($value);
                        if (!$result) {
                            mysql_query("ROLLBACK");
                            die(db_show_error($sql, "DB Execute Failed.", mysql_error()));
                        }
                    }
                }
            } else {
                $result = mysql_query($sql) or die(db_show_error($sql, "DB Execute Failed.", mysql_error()));
            }
            break;
    }
    return $result;
}
开发者ID:RubenMaguregui,项目名称:closesis,代码行数:36,代码来源:database.inc.php

示例6: session_destroy

    session_destroy();
}
if (optional_param('register', '', PARAM_NOTAGS)) {
    if (optional_param('R1', '', PARAM_ALPHA) == 'register') {
        header("Location:register.php");
    }
}
$_REQUEST['USERNAME'] = preg_replace('/[^A-Za-z0-9\\-]/', '', $_REQUEST['USERNAME']);
if (isset($_POST['USERNAME'])) {
    $_POST['USERNAME'] = preg_replace('/[^A-Za-z0-9\\-]/', '', $_POST['USERNAME']);
}
if (isset($_GET['USERNAME'])) {
    $_GET['USERNAME'] = preg_replace('/[^A-Za-z0-9\\-]/', '', $_GET['USERNAME']);
}
if (optional_param('USERNAME', '', PARAM_RAW) && optional_param('PASSWORD', '', PARAM_RAW)) {
    db_start();
    $_REQUEST['USERNAME'] = mysqli_real_escape_string($connection, $_REQUEST['USERNAME']);
    $_REQUEST['PASSWORD'] = mysqli_real_escape_string($connection, $_REQUEST['PASSWORD']);
    # --------------------------- Seat Count Update Start ------------------------------------------ #
    $course_name = DBGet(DBQuery("SELECT DISTINCT(COURSE_PERIOD_ID)FROM schedule WHERE  END_DATE <'" . mysqli_real_escape_string($connection, date("Y-m-d")) . "' AND  DROPPED =  '" . mysqli_real_escape_string($connection, 'N') . "' "));
    foreach ($course_name as $column => $value) {
        $course_count = DBGet(DBQuery("SELECT *  FROM schedule WHERE  COURSE_PERIOD_ID='" . $value[COURSE_PERIOD_ID] . "' AND  END_DATE <'" . date("Y-m-d") . "'AND  DROPPED =  'N' "));
        for ($i = 1; $i <= count($course_count); $i++) {
            DBQuery("CALL SEAT_FILL()");
            DBQuery("UPDATE course_periods SET filled_seats=filled_seats-1 WHERE COURSE_PERIOD_ID IN (SELECT COURSE_PERIOD_ID FROM schedule WHERE end_date IS NOT NULL AND END_DATE  <'" . date("Y-m-d") . "' AND  DROPPED='N' AND COURSE_PERIOD_ID='" . $value[COURSE_PERIOD_ID] . "')");
            DBQuery(" UPDATE schedule SET  DROPPED='Y' WHERE END_DATE  IS NOT NULL AND COURSE_PERIOD_ID='" . $value[COURSE_PERIOD_ID] . "' AND END_DATE  <'" . date("Y-m-d") . "'AND   DROPPED =  'N' AND  STUDENT_ID='" . $course_count[$i][STUDENT_ID] . "'");
        }
    }
    # ---------------------------- Seat Count Update End ------------------------------------------- #
    $username = optional_param('USERNAME', '', PARAM_RAW);
    if ($_REQUEST['remember']) {
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:31,代码来源:index.php

示例7: foreach

     foreach ($courses as $course_id => $count) {
         $courses_list[++$i] = array('COURSE' => _getCourse(substr($course_id, 0, strpos($course_id, '-'))) . substr($course_id, strpos($course_id, '-')), 'COUNT' => $count);
     }
     ListOutput($courses_list, array('COURSE' => 'Course', 'COUNT' => '#'), 'Course with Unscheduled Requests', 'Courses with Unscheduled Requests', '', '', array('sort' => false, 'search' => false));
     $i = 0;
     $courses_list = array();
     if (count($course_seats)) {
         foreach ($course_seats as $course_id => $count) {
             $courses_list[++$i] = array('COURSE' => _getCourse(substr($course_id, 0, strpos($course_id, '-'))) . substr($course_id, strpos($course_id, '-')), 'COUNT' => $count);
         }
     }
     ListOutput($courses_list, array('COURSE' => 'Course', 'COUNT' => '#'), 'Course with No Seats', 'Courses with No Seats', '', '', array('sort' => false, 'search' => false));
     echo '</TD></TR></TABLE>';
 }
 if (!$_SCHEDULER['dont_run']) {
     $connection = db_start();
     db_trans_start($connection);
     unset($_SESSION['SCHEDULE']);
     if (count($insert)) {
         foreach ($insert as $student_id => $requests) {
             foreach ($requests as $request) {
                 $sql = "INSERT INTO SCHEDULE (SYEAR,SCHOOL_ID,STUDENT_ID,START_DATE,MODIFIED_DATE,COURSE_ID,COURSE_WEIGHT,COURSE_PERIOD_ID,MP,MARKING_PERIOD_ID) values('" . UserSyear() . "','" . UserSchool() . "','" . $request['STUDENT_ID'] . "','" . DBDate() . "','" . DBDate() . "','" . $request['COURSE_ID'] . "','" . $request['COURSE_WEIGHT'] . "','" . $request['COURSE_PERIOD_ID'] . "','" . $request['MP'] . "','" . $request['MARKING_PERIOD_ID'] . "')";
                 db_trans_query($connection, $sql);
             }
         }
     }
     foreach ($periods_RET as $course_id => $weights) {
         foreach ($weights as $weight => $periods) {
             foreach ($periods as $course_period_id => $period) {
                 $sql = "UPDATE COURSE_PERIODS SET FILLED_SEATS=COALESCE(TOTAL_SEATS,0)-'" . $period[1]['AVAILABLE_SEATS'] . "' WHERE COURSE_PERIOD_ID='{$course_period_id}'";
                 db_trans_query($connection, $sql);
开发者ID:linil,项目名称:centreSIS,代码行数:31,代码来源:Scheduler_old.php

示例8: db_del

function db_del($key, $subkey = '_')
{
    $id = db_start($key);
    if ($subkey == '*') {
        $res = $_SESSION;
        session_destroy();
    } else {
        $res = nvl($_SESSION, $subkey);
        unset($_SESSION[$subkey]);
        if (empty($_SESSION)) {
            session_destroy();
        }
    }
    db_end($id);
    return $res;
}
开发者ID:rchavik,项目名称:atrocious-saml-dragon,代码行数:16,代码来源:cortolib.php

示例9: DBQueryMod

function DBQueryMod($sql)
{
    global $DatabaseType, $_openSIS;
    $connection = db_start();
    switch ($DatabaseType) {
        case 'mysqli':
            $sql = str_replace('&amp;', "", $sql);
            $sql = str_replace('&quot', "", $sql);
            $sql = str_replace('&#039;', "", $sql);
            $sql = str_replace('&lt;', "", $sql);
            $sql = str_replace('&gt;', "", $sql);
            if (preg_match_all("/'(\\d\\d-[A-Za-z]{3}-\\d{2,4})'/", $sql, $matches)) {
                foreach ($matches[1] as $match) {
                    $dt = date('Y-m-d', strtotime($match));
                    $sql = preg_replace("/'{$match}'/", "'{$dt}'", $sql);
                }
            }
            if (substr($sql, 0, 6) == "BEGIN;") {
                $array = explode(";", $sql);
                foreach ($array as $value) {
                    if ($value != "") {
                        $user_agent = explode('/', $_SERVER['HTTP_USER_AGENT']);
                        if ($user_agent[0] == 'Mozilla') {
                            $result = $connection->query($value);
                        }
                        if (!$result) {
                            $user_agent = explode('/', $_SERVER['HTTP_USER_AGENT']);
                            if ($user_agent[0] == 'Mozilla') {
                                $connection->query("ROLLBACK");
                                die(db_show_error($sql, "DB Execute Failed.", mysql_error()));
                            }
                        }
                    }
                }
            } else {
                $user_agent = explode('/', $_SERVER['HTTP_USER_AGENT']);
                if ($user_agent[0] == 'Mozilla') {
                    $result = $connection->query($sql) or die(db_show_error($sql, "DB Execute Failed.", mysql_error()));
                }
            }
            break;
    }
    return $result;
}
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:44,代码来源:DatabaseInc.php

示例10: sidebar

function sidebar()
{
    $num = 3;
    //人気記事の表示したい件数を入力
    $sql = "SELECT * FROM news,img,category,click_count where show_flg = 1 AND news.news_id = img.news_id AND news.category_id = category.category_id AND news.news_id = click_count.news_id GROUP BY click_count.news_id ORDER BY COUNT(click_count.news_id) DESC LIMIT {$num}";
    db_start($sql);
    $pdo = null;
}
开发者ID:29-takahashi,项目名称:kadai,代码行数:8,代码来源:func.php


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