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


PHP open_database_connection函数代码示例

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


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

示例1: insert_transaction

function insert_transaction($date, $recipient, $category, $amount, $description)
{
    $link = open_database_connection();
    $date = strtotime($date);
    $date = mysql_real_escape_string(date('Y-m-d', $date));
    $recipientName = mysql_real_escape_string(trim($recipient));
    $categoryName = $category;
    $categoryName = mysql_real_escape_string(trim($category));
    $description = mysql_real_escape_string(trim($description));
    $amount = mysql_real_escape_string(trim($amount));
    $checkRecipientQuery = "select id from Recipients where upper(name) like upper('{$recipientName}');";
    $result = mysql_query($checkRecipientQuery, $link);
    if (mysql_num_rows($result) == 0) {
        $createRecipientQuery = "insert into Recipients (name) values ('{$recipientName}');";
        mysql_query($createRecipientQuery, $link);
        $result = mysql_query($checkRecipientQuery, $link);
    }
    $row = mysql_fetch_assoc($result);
    $recipientID = $row['id'];
    $checkCategoryQuery = "select id from Categories where upper(name) like upper('{$categoryName}');";
    $result = mysql_query($checkCategoryQuery, $link);
    if (mysql_num_rows($result) == 0) {
        $createCategoryQuery = "insert into Categories (name) values ('{$categoryName}');";
        mysql_query($createCategoryQuery, $link);
        $result = mysql_query($checkCategoryQuery, $link);
    }
    $row = mysql_fetch_assoc($result);
    $categoryID = $row['id'];
    $createTransactionQuery = "insert into Transactions (date, amount, description, recipientID, categoryID) " . "values ('{$date}', '{$amount}', '{$description}', '{$recipientID}', '{$categoryID}');";
    mysql_query($createTransactionQuery, $link);
    close_database_connection($link);
}
开发者ID:suitengu,项目名称:finance_tool,代码行数:32,代码来源:connection.php

示例2: remove_post

function remove_post($id)
{
    $link = open_database_connection();
    $sql = "DELETE FROM Post WHERE id = {$id}";
    $result = mysql_query($sql, $link);
    close_database_connection($link);
    return $post;
}
开发者ID:KollaneSnake,项目名称:TryToConnectGithub,代码行数:8,代码来源:Model.php

示例3: delete_post

function delete_post($id)
{
    $sql = "DELETE FROM post WHERE id='{$id}'";
    $link = open_database_connection();
    mysql_query($sql, $link);
    close_database_connection($link);
    return;
}
开发者ID:HovinenK,项目名称:Hovinen,代码行数:8,代码来源:model.php

示例4: delete_post

function delete_post($id)
{
    $link = open_database_connection();
    $sql = "DELETE FROM `post` WHERE id='{$id}' ";
    mysql_query($sql, $link) or die("Запрос не выполненн" . mysql_error());
    close_database_connection($link);
    return;
}
开发者ID:BorisRz,项目名称:Zrl,代码行数:8,代码来源:model.php

示例5: get_thing_by_key

function get_thing_by_key($thingKey)
{
    $dbconn = open_database_connection();
    $thingKey = intval($thingKey);
    $result = $dbconn->query("SELECT * FROM things WHERE thingKey = " . $thingKey);
    $row = $result->fetch_assoc();
    close_database_connection($dbconn);
    return $row;
}
开发者ID:howardkitto,项目名称:simpleton,代码行数:9,代码来源:model.php

示例6: insertNewRecord

function insertNewRecord($playerName, $Score)
{
    $connection = open_database_connection();
    $query = "INSERT INTO highscores(Name, Score) VALUES ('{$playerName}', {$Score})";
    print '<br>';
    print $query;
    mysqli_query($connection, $query);
    close_database_connection($connection);
}
开发者ID:B00058026,项目名称:FinalVersion,代码行数:9,代码来源:dbFunctions.php

示例7: get_post

function get_post($id)
{
    $link = open_database_connection();
    $sql = "SELECT * FROM post WHERE id='{$id}'";
    $result = mysql_query($sql, $link);
    $post = mysql_fetch_assoc($result);
    close_database_connection($link);
    return $post;
}
开发者ID:KuzinaValentina,项目名称:kuzina,代码行数:9,代码来源:model.php

示例8: get_post_by_id

/**
 * @param $id
 *
 * @return array|null
 */
function get_post_by_id($id)
{
    $link = open_database_connection();
    $id = intval($id);
    $query = 'SELECT id, title FROM post WHERE id = ' . $id;
    $result = mysqli_query($link, $query);
    $row = mysqli_fetch_assoc($result);
    close_database_connection($link);
    return $row;
}
开发者ID:KnezevicKarlo,项目名称:Symfony,代码行数:15,代码来源:model.php

示例9: get_post_by_id

function get_post_by_id($id)
{
    $link = open_database_connection();
    $id = mysql_real_escape_string($id);
    $query = 'SELECT date, title, body FROM post WHERE id = ' . $id;
    $result = mysql_query($query);
    $row = mysql_fetch_assoc($result);
    close_database_connection($link);
    return $row;
}
开发者ID:rfc1483,项目名称:blog,代码行数:10,代码来源:model.php

示例10: edit_data

function edit_data($id)
{
    $autor = $_POST['autor'];
    $date = date("Y-m-d H:i:s");
    $title = $_POST['title'];
    $edit_content = $_POST['content'];
    $link = open_database_connection();
    $sql = "UPDATE `post` SET `autor` = '{$autor}', `date` = '{$date}', `title` = '{$title}', `content` = '{$edit_content}' WHERE `id` = '{$id}';";
    $add = mysql_query($sql, $link);
    close_database_connection($link);
}
开发者ID:TatjanaLuik,项目名称:luik,代码行数:11,代码来源:model.php

示例11: update_row

function update_row()
{
    if (!($request = getRequest())) {
        return false;
    }
    $sql = "UPDATE `pages` SET `date`='" . $request['date'] . "', \n\t\t\t\t\t\t`title`='" . $request['title'] . "', \n\t\t\t\t\t\t`author`='" . $request['author'] . "', \n\t\t\t\t\t\t`content`='" . $request['content'] . "'  \n\t\t\t\t\t\t WHERE id=" . $request['id'];
    $link = open_database_connection();
    $result = mysql_query($sql, $link) or die("error! " . $sql . " == " . mysql_error());
    close_database_connection($link);
    return $result;
}
开发者ID:deniya,项目名称:mysite,代码行数:11,代码来源:model.php

示例12: get_all_rows

function get_all_rows()
{
    $link = open_database_connection();
    $result = mysql_query('SELECT * FROM pages', $link);
    $rows = array();
    while ($row = mysql_fetch_assoc($result)) {
        $rows[] = $row;
    }
    close_database_connection($link);
    return $rows;
}
开发者ID:bambr325,项目名称:mySite,代码行数:11,代码来源:model.php

示例13: get_all_posts

function get_all_posts()
{
    $link = open_database_connection();
    $result = mysql_query('SELECT id, title FROM post', $link);
    $posts = array();
    while ($row = mysql_fetch_assoc($result)) {
        $posts[] = $row;
    }
    close_database_connection($link);
    return $posts;
}
开发者ID:temarez,项目名称:php2symfony,代码行数:11,代码来源:model.php

示例14: testDeleteCategory

 public function testDeleteCategory()
 {
     // Arrange
     $changeCategory = new ChangeCategory();
     $connection = open_database_connection();
     $expectedResult = $changeCategory->addCategory($connection, "PHP Unit Test Category", "", "", "PHP Unit Test Summary");
     // Act
     $result = $changeCategory->deleteCategory($connection, "PHP Unit Test Category");
     // Assert
     $this->assertEquals($result, $expectedResult);
 }
开发者ID:supermariolegend,项目名称:KBK,代码行数:11,代码来源:ChangeCategoryTest.php

示例15: edit_data

function edit_data($id)
{
    $autor = $_POST['autor'];
    $content = $_POST['content'];
    $title = $_POST['title'];
    $link = open_database_connection();
    $sql = "UPDATE `post` SET `autor` = '{$autor}', `title` = '{$title}', `content` = '{$content}' WHERE `id` = '{$id}';";
    $edit = mysql_query($sql, $link);
    close_database_connection($link);
    header('location:admin');
}
开发者ID:sergeysubbotin,项目名称:subbotin,代码行数:11,代码来源:model.php


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