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


PHP dbConnect函数代码示例

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


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

示例1: CreateNews

function CreateNews($sql)
{
    $dir = __DIR__ . "/../content/";
    move_uploaded_file($_FILES['content']['tmp_name'], $dir . $_FILES['content']['name']);
    dbConnect();
    mysql_query($sql);
}
开发者ID:vostvesh,项目名称:SAA_News,代码行数:7,代码来源:function.php

示例2: editEquipInfo

function editEquipInfo()
{
    if (isset($_POST)) {
        $equipid = $_POST['update_equipid'];
        $equipname = $_POST['edit_equipname'];
        $equiptype = $_POST['edit_equiptype'];
        $status = $_POST['edit_status'];
    }
    $conn = dbConnect();
    if ($conn) {
        $sql = "UPDATE EMM_ZOO.SANITATION_EQUIP SET EQUIPID = '{$equipid}', EQUIPNAME = '{$equipname}' , EQUIPTYPE = '{$equiptype}', STATUS = '{$status}' WHERE EQUIPID = {$equipid};";
        $result = db2_exec($conn, $sql);
        if ($result) {
            echo "<script>";
            echo "alert('Updated successfully')";
            echo "</script>";
            header('Location: sani_equip.php#car_list');
            exit;
        } else {
            $resultMessage = 0;
            echo "<script>";
            echo "alert('Updated unsuccessfully')";
            echo "</script>";
            return $resultMessage;
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
开发者ID:Juklabs,项目名称:emmaline,代码行数:31,代码来源:editEquip.php

示例3: selectReadings

function selectReadings()
{
    $db = dbConnect();
    // $select = $db->query("SELECT * FROM yun");
    $select = $db->query("SELECT * FROM yun ORDER BY time DESC LIMIT 1");
    echo '"value": ' . "[";
    $values = "";
    /*while($row = $select->fetch()) {
      	$values .= $row['value'] . ",";
      }*/
    $values = $select->fetch()['value'];
    $values = rtrim($values, ",");
    echo $values;
    echo "], ";
    // $select = $db->query("SELECT * FROM yun");
    $select = $db->query("SELECT * FROM yun ORDER BY time DESC LIMIT 1");
    echo '"room": ' . '["';
    $rooms = "";
    /*while($row = $select->fetch()) {
        $rooms = 
      }*/
    $rooms = $select->fetch()['room'];
    $rooms = rtrim($rooms, ",");
    echo $rooms;
    echo '"]';
}
开发者ID:RuixuanSunny,项目名称:Find_A_Room,代码行数:26,代码来源:rest.php

示例4: t

 function t()
 {
     $s_tag = $_SERVER['REQUEST_URI'];
     $s_tag = str_replace('/s/t/', '', $s_tag);
     $dbh = dbConnect();
     $sql = "select url from links where short_link = '{$s_tag}'";
     $res = mysql_query($sql, $dbh);
     $row = mysql_fetch_assoc($res);
     $url = $row['url'];
     if (strlen($url) <= 0) {
         return;
     }
     $sql = "select clicks from links where short_link = '{$s_tag}'";
     $res = mysql_query($sql, $dbh);
     $row = mysql_fetch_assoc($res);
     $clicks = (int) $row['clicks'];
     $clicks++;
     $sql = "update links set clicks = {$clicks} where short_link = '{$s_tag}'";
     $res = mysql_query($sql, $dbh);
     mysql_close($dbh);
     header("location: {$url}");
     echo "<script>\n";
     echo "window.location='{$url}';";
     echo "</script>\n";
 }
开发者ID:barce,项目名称:ezmvc,代码行数:25,代码来源:s.php

示例5: markSessionExpired

function markSessionExpired($id)
{
    $conn = dbConnect();
    $sql = " UPDATE fbUsers SET `sessionExpires`='" . date("Y-m-d", strtotime('yesterday')) . "' WHERE id='{$id}'";
    mysql_query($sql, $conn);
    mysql_close($conn);
}
开发者ID:BGCX067,项目名称:facebook-jewishdates-svn-to-git,代码行数:7,代码来源:postFeeds.php

示例6: addContact

function addContact()
{
    $conn = dbConnect();
    $name = '';
    $email = '';
    $mobile = '';
    $position = '';
    if (isset($_POST['name'])) {
        $name = $conn->real_escape_string($_POST['name']);
    }
    if (isset($_POST['email'])) {
        $email = $conn->real_escape_string($_POST['email']);
    }
    if (isset($_POST['mobile'])) {
        $mobile = $conn->real_escape_string($_POST['mobile']);
    }
    if (isset($_POST['position'])) {
        $position = $conn->real_escape_string($_POST['position']);
    }
    $sql = "INSERT into contactus(name,position,email,mobile) VALUES('{$name}','{$position}','{$email}','{$mobile}')";
    $result = $conn->query($sql);
    dbDisconnect($conn);
    if ($result) {
        header("location:../contact.php");
    } else {
        echo "Some error occured..:(";
    }
}
开发者ID:ncs-jss,项目名称:zealicon15_backoffice,代码行数:28,代码来源:add_contact.php

示例7: list_part

function list_part()
{
    header('Content-Type: application/json');
    // get database connection object
    $pdo = dbConnect();
    try {
        $sql = 'SELECT
						tbPart.id AS "PID",  
			 			tbPart.descr AS "DESCRIPTION", 
			 			tbPart.image AS "IMAGE",
						IFNULL(tbDrawing.drawing_number,"") AS "DRAWING"
			 		FROM tbPart
			 		LEFT JOIN tbDrawing ON tbPart.id = tbDrawing.partid
			 		ORDER BY PID';
        $s = $pdo->prepare($sql);
        $s->execute();
        $results = $s->fetchAll();
        $th = array('PID', 'DESCRIPTION', 'DRAWING');
    } catch (PDOException $e) {
        $error = 'Error getting Type list:<br>' . $e->getMessage();
        echo $error;
    }
    // send $results array
    echo json_encode($results);
}
开发者ID:neas5791,项目名称:dbPart2,代码行数:25,代码来源:part.php

示例8: db_query

function db_query($sql, $proxyFields)
{
    $con = dbConnect();
    if ($con == null) {
        return null;
    }
    foreach (array_keys($proxyFields) as $key) {
        $value = mysqli_real_escape_string($con, $proxyFields[$key]);
        if (is_string($value)) {
            $value = "\"{$value}\"";
        }
        $sql = str_replace($key, $value, $sql);
    }
    $result = mysqli_query($con, $sql);
    if (!$result) {
        echo "has error";
        print_r(debug_backtrace());
        $firstCall = end(debug_backtrace());
        $errMsg = "Error calling " . $firstCall["function"];
        $errMsg .= " on line " . $firstCall["line"];
        $errMsg .= " in " . $firstCall["file"] . ": " . mysqli_error($con);
        dbErrorMsg($errMsg);
        return false;
    } else {
        if (strpos($sql, "INSERT") !== false) {
            return mysqli_insert_id($con);
        } else {
            return new result($result);
        }
    }
    dbClose($con);
}
开发者ID:ChapResearch,项目名称:CROMA,代码行数:32,代码来源:drupalCompatibility.php

示例9: makeContent

function makeContent($user, $password)
{
    if (isset($_GET['dbConnect'])) {
        createFormular($GLOBALS['formularAction']);
        dbConnect($user, $password);
    } elseif (isset($_GET['dbShowAll'])) {
        createFormular($GLOBALS['formularAction']);
        listCompany($user, $password);
    } elseif (isset($_GET['logout'])) {
        createFormular($GLOBALS['formularAction']);
        session_start();
        unset($_SESSION);
        session_destroy();
        session_write_close();
        header('Location: http://localhost/');
        die;
    } elseif (isset($_GET['dbAdd'])) {
        createFormular($GLOBALS['formularAction']);
        createDBAddFormular($GLOBALS['formularAction']);
    } elseif (isset($_GET['dbTryAdd'])) {
        createFormular($GLOBALS['formularAction']);
        createDBAddFormular($GLOBALS['formularAction']);
        addCompany($user, $password);
    } elseif (isset($_GET['dbDel'])) {
        createFormular($GLOBALS['formularAction']);
        createDBDelFormular($GLOBALS['formularAction']);
    } elseif (isset($_GET['dbTryDel'])) {
        createFormular($GLOBALS['formularAction']);
        createDBDelFormular($GLOBALS['formularAction']);
        delCompany($user, $password);
    } else {
        createFormular($GLOBALS['formularAction']);
    }
}
开发者ID:Kappao,项目名称:code,代码行数:34,代码来源:my_content_req.php

示例10: editCarPlate

function editCarPlate()
{
    if (isset($_POST)) {
        $carid = $_POST['update_carid'];
        $carplate = $_POST['edit_carplate'];
    }
    $conn = dbConnect();
    if ($conn) {
        $sql = "UPDATE EMM_ZOO.SANICAR SET CARID = '{$carid}', CARPLATE = '{$carplate}' WHERE CARID = {$carid};";
        $result = db2_exec($conn, $sql);
        if ($result) {
            echo "<script>";
            echo "alert('Updated successfully')";
            echo "</script>";
            header('Location: sani_garbage.php#car_list');
            exit;
        } else {
            $resultMessage = 0;
            echo "<script>";
            echo "alert('Updated unsuccessfully')";
            echo "</script>";
            return $resultMessage;
        }
        db2_free_stmt($stmt);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg();
    }
}
开发者ID:Juklabs,项目名称:emmaline,代码行数:29,代码来源:editCar.php

示例11: getListOfBuyClicks

function getListOfBuyClicks($dt)
{
    global $mycatid;
    $str = "";
    $lnk = dbConnect('localhost', 'root', 'lyntik');
    $query = "SELECT b.fdate as fdate,b.ip as cip,b.goodid as gid,b.name as sname,b.source as src,b.price as price  FROM buylog b WHERE b.date='{$dt}' AND b.mycat_id={$mycatid} ORDER BY b.ip,b.fdate";
    $res = exec_query($query);
    $ip = "0.0.0.0";
    $i = 0;
    $str .= "<div class=\"all_clicks\">";
    $str .= "<div class=\"click_row_title\">\n             <div class=\"left click_date title\">Дата</div>\n             <div class=\"left click_id title\">ID товара</div>\n             <div class=\"left click_name title\">Наименование</div>\n             <div class=\"left click_id title\">Цена</div>\n             <div class=\"left click_name title\">Источник</div>\n             " . closeFloat() . "\n            </div>";
    if (mysql_num_rows($res) == 0) {
        $str .= "<div>За выбранную дату нажатий не было</div>";
    } else {
        while ($rows = fetch_array($res)) {
            if ($ip != $rows['cip']) {
                $ip = $rows['cip'];
                if ($i != 0) {
                    $str .= "</div>";
                }
                $str .= "<div class=\"ipclicks\">";
                $str .= "<div class=\"client_ip\">Клики с адреса:<b>" . $rows['cip'] . "</b></div>";
            }
            $str .= "<div class=\"click_row\">\n             <div class=\"left click_date\">" . $rows['fdate'] . "</div>\n             <div class=\"left click_id\">" . $rows['gid'] . "</div>\n             <div class=\"left click_name\">" . $rows['sname'] . "</div>\n             <div class=\"left click_id\">" . $rows['price'] . "</div>\n             <div class=\"left click_name\">" . $rows['src'] . "</div>\n             " . closeFloat() . "\n            </div>";
        }
        $str .= "</div>";
    }
    $str .= "</div></div>";
    mysql_free_result($res);
    dbDisconnect($lnk);
    return $str;
}
开发者ID:xent1986,项目名称:ychebgit,代码行数:32,代码来源:myhist.php

示例12: checkIn

function checkIn()
{
    if (isset($_POST)) {
        $carregno = $_POST['carregno'];
        $carzone = $_POST['parkzone'];
    }
    $conn = dbConnect();
    if ($conn) {
        $insert_checkinout = "INSERT INTO EMM_ZOO.PARKCHECKINOUT (TICKETPARKID, CARREGNO, ZONES, DATES, CHECKIN, CHECKOUT) VALUES (DEFAULT, '{$carregno}', '{$carzone}', current date, current time, null);";
        //echo $insert_checkinout;
        $stmt1 = db2_exec($conn, $insert_checkinout);
        if ($stmt1) {
            $insert_his = "INSERT INTO EMM_ZOO.PARKHISTORY (VEHI_ID, VEHI_REGNO, CHECKIN, CHECKOUT, DATES, FEE) VALUES (DEFAULT, '{$carregno}', current time, null, current date, 0.00);";
            $stmt2 = db2_exec($conn, $insert_his);
            // $sql3 = "UPDATE EMM_ZOO.ANIMAL SET CAGEID = " . $cage . " WHERE ANIMALID = '" . $animal . "';";
            //$rc2 = db2_exec($conn, $sql3);
        }
        if ($stmt1 & $stmt2) {
            header("Refresh:0; url=checkinout.php");
        } else {
            header("Refresh:0; url=checkinout.php");
        }
        db2_free_stmt($stmt1);
        db2_free_stmt($stmt2);
        db2_close($conn);
    } else {
        echo db2_conn_errormsg($conn);
    }
    db2_free_stmt($stmt1);
}
开发者ID:Juklabs,项目名称:emmaline,代码行数:30,代码来源:controller.php

示例13: runQueries

/**
 * Establishes and checks connection to the database and runs the provided queries. 
 * Finally, it outputs JSON that the App will parse. 
 *
 * @param sqlToAvail the SQl query to make machines available
 * @param sqlUpdate the SQL query to update the database
 * @param sqlQuery the SQL query that will output information from the database 
*/
function runQueries($sqlToAvail, $sqlUpdate, $sqlQuery)
{
    $link = dbConnect();
    if (mysqli_connect_errno()) {
        echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
    if (isset($sqlToAvail)) {
        mysqli_query($link, $sqlToAvail);
    }
    if (isset($sqlUpdate)) {
        mysqli_query($link, $sqlUpdate);
    }
    if (isset($sqlQuery)) {
        $result = mysqli_query($link, $sqlQuery);
        if (isset($result)) {
            $resultArray = array();
            $tempArray = array();
            while ($row = $result->fetch_object()) {
                $tempArray = $row;
                array_push($resultArray, $tempArray);
            }
            echo json_encode($resultArray);
        }
    }
    mysqli_close($link);
}
开发者ID:rhondusmithwick,项目名称:DukeLaundryPublic,代码行数:34,代码来源:servicehelp.php

示例14: verifAcces

function verifAcces($id, $mdp)
{
    /*
     * Définition des variables globales $idIsValid et $mdpIsValid
     * permettant de vérifier que l'identifiant et le mot de passe entrés
     * sont corrects.
     */
    global $idIsValid, $mdpIsValid;
    $idIsValid = $mdpIsValid = false;
    global $currentID, $currentMdp;
    $currentID = $id;
    $currentMdp = $mdp;
    // connexion à la base de données de swip
    dbConnect();
    // liste de tous les administrateurs et comparaisons avec l'identifiant et le mot de passe donnés
    $sqlQuery = "select * from administrators;";
    processSqlQuery($sqlQuery, function ($resp) {
        global $idIsValid, $mdpIsValid, $currentID, $currentMdp;
        // pour chaque entrée trouvée
        while ($data = mysql_fetch_assoc($resp)) {
            if ($currentID == $data['id']) {
                $idIsValid = true;
                if ($currentMdp == $data['mdp']) {
                    $mdpIsValid = true;
                }
            }
        }
    });
    return $idIsValid && $mdpIsValid;
}
开发者ID:elodieT,项目名称:Swip,代码行数:30,代码来源:sessions.php

示例15: executeQuery

function executeQuery($query)
{
    // call the dbConnect function
    $conn = dbConnect();
    try {
        // execute query and assign results to a PDOStatement object
        $stmt = $conn->query($query);
        do {
            if ($stmt->columnCount() > 0) {
                $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
                //retreive the rows as an associative array
            }
        } while ($stmt->nextRowset());
        // if multiple queries are executed, repeat the process for each set of results
        //Uncomment these 4 lines to display $results
        //    echo '<pre style="font-size:large">';
        //   print_r($results);
        //    echo '</pre>';
        //   die;
        //call dbDisconnect() method to close the connection
        dbDisconnect($conn);
        return $results;
    } catch (PDOException $e) {
        //if execution fails
        dbDisconnect($conn);
        die('Query failed: ' . $e->getMessage());
    }
}
开发者ID:riFaulkner,项目名称:PHP_easydinner,代码行数:28,代码来源:dbConnExec.php


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