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


PHP connectToDatabase函数代码示例

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


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

示例1: getDetails

function getDetails($db, $id, $type, $langs, $offset)
{
    global $format;
    global $callback;
    // request
    $request = "SELECT\n\t\t\t\ttags->'addr:street' AS \"street\",\n\t\t\t\ttags->'addr:housenumber' AS \"housenumber\",\n\t\t\t\ttags->'addr:country' AS \"country\",\n\t\t\t\ttags->'addr:postcode' AS \"postcode\",\n\t\t\t\ttags->'addr:city' AS \"city\",\n\t\t\t\ttags->'addr:housename' AS \"housename\",\n\t\t\t\ttags->'addr:suburb' AS \"suburb\",\n\t\t\t\ttags->'addr:province' AS \"province\",\n\t\t\t\ttags->'addr:unit' AS \"unit\",\n\t\t\t\ttags->'addr:floor' AS \"floor\",\n\t\t\t\ttags->'addr:door' AS \"door\",\n\t\t\t\ttags->'wikipedia' AS \"wikipedia\",\n\t\t\t\ttags->'phone' AS \"phone1\",\n\t\t\t\ttags->'contact:phone' AS \"phone2\",\n\t\t\t\ttags->'addr:phone' AS \"phone3\",\n\t\t\t\ttags->'phone:mobile' AS \"mobilephone1\",\n\t\t\t\ttags->'contact:mobile' AS \"mobilephone2\",\n\t\t\t\ttags->'fax' AS \"fax1\",\n\t\t\t\ttags->'contact:fax' AS \"fax2\",\n\t\t\t\ttags->'addr:fax' AS \"fax3\",\n\t\t\t\ttags->'website' AS \"website1\",\n\t\t\t\ttags->'url' AS \"website2\",\n\t\t\t\ttags->'url:official' AS \"website3\",\n\t\t\t\ttags->'contact:website' AS \"website4\",\n\t\t\t\ttags->'operator' AS \"operator\",\n\t\t\t\ttags->'email' AS \"email1\",\n\t\t\t\ttags->'contact:email' AS \"email2\",\n\t\t\t\ttags->'addr:email' AS \"email3\",\n\t\t\t\ttags->'opening_hours' AS \"openinghours\",\n\t\t\t\ttags->'service_times' AS \"servicetimes\",\n\t\t\t\ttags->'fee' AS \"fee\",\n\t\t\t\ttags->'toll' AS \"toll\",\n\t\t\t\ttags->'ref' AS \"ref\",\n\t\t\t\ttags->'capacity' AS \"capacity\",\n\t\t\t\ttags->'internet_access' AS \"internet_access\",\n\t\t\t\ttags->'image' AS \"image\",\n\t\t\t\ttags->'image:panorama' AS \"panorama\",\n\t\t\t\ttags->'description' AS \"description\",\n\t\t\t\ttags->'stars' AS \"stars\",\n\t\t\t\ttags->'cuisine' AS \"cuisine\",\n\t\t\t\ttags->'smoking' AS \"smoking\",\n\t\t\t\ttags->'biergarten' AS \"biergarten\",\n\t\t\t\ttags->'beer_garden' AS \"beer_garden\",\n\t\t\t\ttags->'brewery' AS \"beer\",\n\t\t\t\ttags->'microbrewery' AS \"microbrewery\",\n\t\t\t\ttags->'fuel:diesel' AS \"diesel\",\n\t\t\t\ttags->'fuel:GTL_diesel' AS \"gtldiesel\",\n\t\t\t\ttags->'fuel:HGV_diesel' AS \"hgvdiesel\",\n\t\t\t\ttags->'fuel:biodiesel' AS \"biodiesel\",\n\t\t\t\ttags->'fuel_octane_91' AS \"octane91\",\n\t\t\t\ttags->'fuel:octane_95' AS \"octane95\",\n\t\t\t\ttags->'fuel:octane_98' AS \"octane98\",\n\t\t\t\ttags->'fuel:octane_100' AS \"octane100\",\n\t\t\t\ttags->'fuel:octane_98_leaded' AS \"octane98l\",\n\t\t\t\ttags->'fuel:1_25' AS \"fuel25\",\n\t\t\t\ttags->'fuel:1_50' AS \"fuel50\",\n\t\t\t\ttags->'fuel:alcohol' AS \"alcohol\",\n\t\t\t\ttags->'fuel:ethanol' AS \"ethanol\",\n\t\t\t\ttags->'fuel:methanol' AS \"methanol\",\n\t\t\t\ttags->'fuel:svo' AS \"svo\",\n\t\t\t\ttags->'fuel:e85' AS \"e85\",\n\t\t\t\ttags->'fuel:biogas' AS \"biogas\",\n\t\t\t\ttags->'fuel:lpg' AS \"lpg\",\n\t\t\t\ttags->'fuel:cng' AS \"cng\",\n\t\t\t\ttags->'fuel:LH2' AS \"lh2\",\n\t\t\t\ttags->'fuel:electricity' AS \"electro\",\n\t\t\t\ttags->'fuel:adblue' AS \"adblue\",\n\t\t\t\ttags->'car_wash' AS \"carwash\",\n\t\t\t\ttags->'car_repair' AS \"carrepair\",\n\t\t\t\ttags->'shop' AS \"shop\",\n\t\t\t\ttags->'kiosk' AS \"kiosk\",\n\t\t\t\ttags->'ele' AS \"ele\",\n\t\t\t\ttags->'population' AS \"population\",\n\t\t\t\ttags->'iata' AS \"iata\",\n\t\t\t\ttags->'icao' AS \"icao\",\n\t\t\t\ttags->'disused' AS \"disused\",\n\t\t\t\ttags->'wheelchair' AS \"wheelchair\",\n\t\t\t\ttags->'wheelchair:toilets' AS \"wheelchair:toilets\",\n\t\t\t\ttags->'wheelchair:rooms' AS \"wheelchair:rooms\",\n\t\t\t\ttags->'wheelchair:access' AS \"wheelchair:access\",\n\t\t\t\ttags->'wheelchair:places' AS \"wheelchair:places\"\n\t\t\tFROM " . $type . "s WHERE (id = " . $id . ");";
    $wikipediarequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 9) = 'wikipedia';";
    $namerequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 4) = 'name';";
    // connnecting to database
    $connection = connectToDatabase($db);
    // if there is no connection
    if (!$connection) {
        exit;
    }
    $response = requestDetails($request, $connection);
    $wikipediaresponse = requestDetails($wikipediarequest, $connection);
    $nameresponse = requestDetails($namerequest, $connection);
    pg_close($connection);
    if ($response) {
        if ($format == "text") {
            echo textMoredetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset);
        } else {
            if ($format == "json") {
                echo jsonMoredetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type, $callback);
            } else {
                echo xmlMoredetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type);
            }
        }
        return true;
    } else {
        return false;
    }
}
开发者ID:dieterdreist,项目名称:OpenLinkMap,代码行数:33,代码来源:extdetails.php

示例2: returnResultForQuery

function returnResultForQuery($query)
{
    $connection = connectToDatabase();
    $result = $connection->query($query);
    $connection->close();
    return $result;
}
开发者ID:robert-vo,项目名称:Bowling-Score-Tracking-System,代码行数:7,代码来源:databaseFunctions.php

示例3: getUser

function getUser($username)
{
    $mysql = connectToDatabase();
    $query = $mysql->prepare("SELECT * FROM accounts  WHERE username = :username LIMIT 1");
    $query->execute(array('username' => $username));
    return $query->fetch(PDO::FETCH_OBJ);
}
开发者ID:cryptixcoder,项目名称:Stripe-Course,代码行数:7,代码来源:database.php

示例4: importOsmFile

function importOsmFile($filename, $db)
{
    global $offset, $offsetfactorrels, $connection;
    $connection = connectToDatabase($db);
    // if there is no connection
    if (!$connection) {
        reportError("Cannot connect to database.");
        return false;
    }
    $result = pg_query($connection, "TRUNCATE nodes");
    $result = pg_query($connection, "TRUNCATE ways");
    $result = pg_query($connection, "TRUNCATE relations");
    $xml_parser = xml_parser_create();
    xml_set_element_handler($xml_parser, "startElement", "endElement");
    if (!($fp = fopen($filename, "r"))) {
        reportError("Cannot open file.");
        return false;
    }
    while ($data = fread($fp, 4096)) {
        if (!xml_parse($xml_parser, $data, feof($fp))) {
            reportError("XML-Error.");
            return false;
        }
    }
    xml_parser_free($xml_parser);
    fclose($fp);
    pg_close($connection);
    echo "Finished " . $db . "...\n";
    return true;
}
开发者ID:dieterdreist,项目名称:OpenLinkMap,代码行数:30,代码来源:import.php

示例5: doGet

function doGet()
{
    global $smarty;
    global $db;
    require_once "./config.php";
    $db = connectToDatabase();
    smartysetup();
    $mvname = $_GET['mvn'];
    $query = 'movie = ?';
    $mvm = new Moviemains();
    $infos = $mvm->Find($query, $mvname);
    /**single movie*/
    $mcomms = array();
    $mpics = array();
    $querys = 'fk_movie = ?';
    $mvs = new Moviesupps();
    $supinfos = array();
    $supinfos = $mvs->Find($querys, $infos[0]->id);
    foreach ($supinfos as $supin) {
        $mcomms[] = $supin->photocomment;
        $mpics[] = $supin->photo;
    }
    $snums = count($mpics) - 1;
    $smarty->assign('num', $snums);
    $smarty->assign('name', $mvname);
    $smarty->assign('cat', $infos[0]->mgroup);
    $smarty->assign('info', $infos[0]->info);
    $smarty->assign('comms', $mcomms);
    $smarty->assign('pics', $mpics);
    $smarty->display('SearchResult.tpl');
}
开发者ID:bearwithcode,项目名称:Victor,代码行数:31,代码来源:SearchResult.php

示例6: displayConfigForm

function displayConfigForm()
{
    $query = "SELECT * FROM vars_text";
    $query_2 = "SELECT * FROM vars_numeric";
    $database = connectToDatabase();
    $result = mysqlQuery($query, $database);
    $result_2 = mysqlQuery($query_2, $database);
    echo "<form method='post'><table>";
    while ($result_array = mysql_fetch_array($result)) {
        //debugArray( "text", $result_array );
        echo "<tr>";
        echo "<td>";
        echo "<input type='text' name='text_" . $result_array['name'] . "' value='" . $result_array['value'] . "' size='50' />";
        echo "</td>";
        echo "<td>";
        echo $result_array['description'];
        echo "</td>";
        echo "</tr>";
    }
    while ($result_array_2 = mysql_fetch_array($result_2)) {
        echo "<tr>";
        echo "<td>";
        echo "<input type='text' name='" . $result_array_2['name'] . "' value='" . $result_array_2['value'] . "' size='50' />";
        echo "</td>";
        echo "<td>";
        echo $result_array_2['description'];
        echo "</td>";
        echo "</tr>";
    }
    echo "<tr>";
    echo "<td><input type='submit' value='Submit' /></td><td><input type='hidden' name='submitted' value='1' /></td></tr>";
    echo "</table></form>";
}
开发者ID:fbrier,项目名称:open-configurator,代码行数:33,代码来源:edit_config.php

示例7: getDetails

function getDetails($ptdb, $id, $type, $langs, $offset)
{
    global $format, $callback;
    // request
    $wikipediarequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 9) = 'wikipedia';";
    $namerequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 4) = 'name';";
    // connnecting to database
    $connection = connectToDatabase($ptdb);
    // if there is no connection
    if (!$connection) {
        exit;
    }
    $wikipediaresponse = requestDetails($wikipediarequest, $connection);
    $nameresponse = requestDetails($namerequest, $connection);
    pg_close($connection);
    $response = tagTransform("../locales/departures.xml", getTags($ptdb, $id, $type), $type);
    if ($response) {
        if ($format == "text") {
            echo textDetailsOut($response, $nameresponse, $wikipediaresponse, $langs, $offset);
        } else {
            if ($format == "json") {
                echo jsonDetailsOut($response, $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type, $callback);
            } else {
                echo xmlDetailsOut($response, $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type);
            }
        }
        return true;
    } else {
        return false;
    }
}
开发者ID:dieterdreist,项目名称:OpenLinkMap,代码行数:31,代码来源:ptdetails.php

示例8: doLogin

function doLogin($referer_in, $post)
{
    extract($post);
    if ($submit_login) {
        if (!recaptchaCheck()) {
            return 0;
        }
        $database = connectToDatabase();
        $account = new Account($username);
        if ($account->checkPassword($password)) {
            session_name($username);
            $_SESSION['username'] = $username;
            $_SESSION['id'] = $account->getDatabaseID();
            if ($referer) {
                doRedirect($referer);
            } else {
                renderError("Cannot redirect you to the proper place.  Please press the back button and try again.");
                return 0;
            }
        } else {
            renderError("Your password is incorrect.  Please try again");
            return 0;
        }
    } else {
        renderError("You need to login to do that.");
        displayLoginForm($referer_in);
        return 0;
    }
}
开发者ID:fbrier,项目名称:open-configurator,代码行数:29,代码来源:login.php

示例9: getDetails

function getDetails($db, $id, $type, $langs, $offset)
{
    global $format, $callback;
    // request
    $request = "SELECT\n\t\t\t\ttags->'addr:street' AS \"street\",\n\t\t\t\ttags->'addr:housenumber' AS \"housenumber\",\n\t\t\t\ttags->'addr:housename' AS \"housename\",\n\t\t\t\ttags->'addr:country' AS \"country\",\n\t\t\t\ttags->'addr:postcode' AS \"postcode\",\n\t\t\t\ttags->'addr:city' AS \"city\",\n\t\t\t\ttags->'addr:suburb' AS \"suburb\",\n\t\t\t\ttags->'addr:province' AS \"province\",\n\t\t\t\ttags->'addr:unit' AS \"unit\",\n\t\t\t\ttags->'addr:floor' AS \"floor\",\n\t\t\t\ttags->'addr:door' AS \"door\",\n\t\t\t\ttags->'phone' AS \"phone1\",\n\t\t\t\ttags->'contact:phone' AS \"phone2\",\n\t\t\t\ttags->'addr:phone' AS \"phone3\",\n\t\t\t\ttags->'fax' AS \"fax1\",\n\t\t\t\ttags->'contact:fax' AS \"fax2\",\n\t\t\t\ttags->'addr:fax' AS \"fax3\",\n\t\t\t\ttags->'website' AS \"website1\",\n\t\t\t\ttags->'url' AS \"website2\",\n\t\t\t\ttags->'url:official' AS \"website3\",\n\t\t\t\ttags->'contact:website' AS \"website4\",\n\t\t\t\ttags->'operator' AS \"operator\",\n\t\t\t\ttags->'email' AS \"email1\",\n\t\t\t\ttags->'contact:email' AS \"email2\",\n\t\t\t\ttags->'addr:email' AS \"email3\",\n\t\t\t\ttags->'opening_hours' AS \"openinghours\",\n\t\t\t\ttags->'service_times' AS \"servicetimes\",\n\t\t\t\ttags->'image' AS \"image\"\n\t\t\tFROM " . $type . "s WHERE (id = " . $id . ");";
    $wikipediarequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 9) = 'wikipedia';";
    $namerequest = "SELECT\n\t\t\t\t\t\t\t\tfoo.keys, foo.values\n\t\t\t\t\t\t\tFROM (\n\t\t\t\t\t\t\t\tSELECT\n\t\t\t\t\t\t\t\t\tskeys(tags) AS keys,\n\t\t\t\t\t\t\t\t\tsvals(tags) AS values\n\t\t\t\t\t\t\t\tFROM " . $type . "s\n\t\t\t\t\t\t\t\tWHERE (id = " . $id . ")\n\t\t\t\t\t\t\t) AS foo\n\t\t\t\t\t\t\tWHERE substring(foo.keys from 1 for 4) = 'name';";
    // connnecting to database
    $connection = connectToDatabase($db);
    // if there is no connection
    if (!$connection) {
        exit;
    }
    $response = requestDetails($request, $connection);
    $wikipediaresponse = requestDetails($wikipediarequest, $connection);
    $nameresponse = requestDetails($namerequest, $connection);
    pg_close($connection);
    if ($response) {
        if ($format == "text") {
            echo textDetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset);
        } else {
            if ($format == "json") {
                echo jsonDetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type, $callback);
            } else {
                echo xmlDetailsOut($response[0], $nameresponse, $wikipediaresponse, $langs, $offset, $id, $type);
            }
        }
        return true;
    } else {
        return false;
    }
}
开发者ID:dieterdreist,项目名称:OpenLinkMap,代码行数:32,代码来源:details.php

示例10: execute

function execute($sql)
{
    global $invalidQueryInputError;
    $connection = connectToDatabase();
    $result = mysqli_query($connection, $sql);
    closeConnection($connection);
    $rows = array();
    if (mysqli_num_rows($result) > 0) {
        $i = 0;
        while ($row = mysqli_fetch_assoc($result)) {
            $rows[$i] = $row;
            $i++;
        }
    }
    if ($invalidQueryInputError != "") {
        $rows["PHP_ERROR"] = $invalidQueryInputError;
        //This is not safe [Security Flow]
        $invalidQueryInputError = "";
    }
    if (mysqli_error($connection) != null) {
        $rows["SQL_ERROR"] = mysqli_connect_error();
        //This is not safe [Security Flow]
    }
    return $rows;
}
开发者ID:Dorgam,项目名称:ICS324_GROUP_2,代码行数:25,代码来源:DBO.php

示例11: comparePermission

function comparePermission($userName)
{
    $db = connectToDatabase();
    foreach ($db->query("SELECT * FROM cred WHERE userName ='" . $userName . "'") as $row) {
        $row;
        return $row;
    }
}
开发者ID:aluminium22,项目名称:cit313,代码行数:8,代码来源:functions.php

示例12: getPage

function getPage($action)
{
    $db = connectToDatabase();
    foreach ($db->query("SELECT * FROM " . $action) as $row) {
        $row;
        return $row;
    }
}
开发者ID:aluminium22,项目名称:cit313,代码行数:8,代码来源:pages.php

示例13: printPlayersReport

function printPlayersReport($report, $showTop, $orderBy)
{
    $conn = connectToDatabase();
    $query = 'SELECT * FROM Player_Stats, Players where Player_Stats.Player_ID = Players.Player_ID and Player_Stats.' . $report . ' > 0 ORDER BY Player_Stats.' . $report . ' ' . $orderBy . ' LIMIT ' . $showTop . ';';
    $result = $conn->query($query);
    printPlayers($report, $result);
    $conn->close();
}
开发者ID:robert-vo,项目名称:Bowling-Score-Tracking-System,代码行数:8,代码来源:getReport.php

示例14: printBallPopularity

function printBallPopularity($orderBy, $showTop)
{
    $conn = connectToDatabase();
    $query = "SELECT roll.Ball_ID, Count(roll.Ball_ID) as numOfRolls, ball.Color, ball.Weight, ball.Size\n                FROM roll, ball\n                WHERE roll.Ball_ID = ball.Ball_ID\n                GROUP by Ball_ID\n                ORDER BY COUNT(Ball_ID) {$orderBy} LIMIT {$showTop}";
    $result = $conn->query($query);
    printTable($result);
    $conn->close();
}
开发者ID:robert-vo,项目名称:Bowling-Score-Tracking-System,代码行数:8,代码来源:ballReport.php

示例15: search

function search($input)
{
    $db = connectToDatabase();
    $gem = $input;
    foreach ($db->query("SELECT * FROM stones WHERE name ='" . $gem . "'") as $row) {
        $row;
        return $row;
    }
}
开发者ID:aluminium22,项目名称:cit313,代码行数:9,代码来源:gemquery.php


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