• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP open_database_connection函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: getAllFromById

function getAllFromById($tableName, $id)
{
    $link = open_database_connection();
    $result = mysql_query('SELECT * FROM $tableName WHERE id = $id', $link);
    $posts = array();
    while ($row = mysql_fetch_assoc($result)) {
        $posts[] = $row;
    }
    close_database_connection($link);
    return $posts;
}
开发者ID:Ryzoo,项目名称:Przyklad-aplikacji,代码行数:11,代码来源:databaseFunction.php


示例17: add_post

function add_post()
{
    $author = $_POST['add_author'];
    $time = $_POST['add_time'];
    $title = $_POST['add_title'];
    $content = $_POST['add_content'];
    $link = open_database_connection();
    $sql = "INSERT INTO `post` (`id`, `author`, `time`, `title`, `content`) \n\t\t\tVALUES (NULL, '{$author}', '{$time}', '{$title}', '{$content}');";
    $result = mysql_query($sql, $link);
    close_database_connection($link);
}
开发者ID:VassiljevaGalina,项目名称:Vassiljeva,代码行数:11,代码来源:model.php


示例18: get_row

function get_row($id)
{
    $link = open_database_connection();
    $sql = "SELECT * FROM `idpages` WHERE `id`={$id}";
    $result = mysql_query($sql, $link);
    $rows = array();
    while ($row = mysql_fetch_array($result)) {
        $rows[] = $row;
    }
    close_database_connection($link);
    return $rows;
}
开发者ID:Olikainen,项目名称:mysite,代码行数:12,代码来源:model.php


示例19: get_all_posts

function get_all_posts()
{
    $link = open_database_connection();
    $sql = 'SELECT * FROM posts';
    $result = mysqli_query($link, $sql);
    $posts = array();
    while ($row = mysqli_fetch_array($result, MYSQL_ASSOC)) {
        $posts[] = $row;
    }
    close_db_connection($link);
    return $posts;
}
开发者ID:hollandlive,项目名称:ivik,代码行数:12,代码来源:model.php


示例20: getImageUrlArray

 /**
  * @return array
  */
 public function getImageUrlArray()
 {
     // make a new connection to the database
     $connection = open_database_connection();
     // make a new query for the CategoryID and ProductImageURL from all rows from `products`
     $query = "SELECT CategoryID, ProductImageURL FROM `products` ORDER BY CategoryID ASC";
     // get the results from the query
     $results = mysqli_query($connection, $query);
     // declare imageData to be an empty array
     // this variable will hold all the data in php array format before we json_encode() it
     $imageData = array();
     // declaring and defining a variable to represent which category(the CategoryID)
     // we're processing in the loop below
     $categoryToProcess = 0;
     // declaring and defining a variable to represent which index in its respective
     // category array in imageData we're processing
     $categoryIndexToProcess = 0;
     // check to make sure there are results from the mysql query we made earlier
     if (mysqli_num_rows($results) > 0) {
         // as long as we can retrieve another row from the database, add the row's ProductImageURL to imageData
         while ($rows = $results->fetch_assoc()) {
             // set the category we're processing to be the CategoryID of the row we retrieved
             $categoryToProcess = $rows['CategoryID'];
             if (array_key_exists($categoryToProcess, $imageData)) {
                 // If an array key exists in the object for the category we're processing,
                 // then there is an array dedicated to storing data for that category, so
                 // insert the image url in the category's array, in the next index
                 $imageData[$categoryToProcess][$categoryIndexToProcess] = "/images/" . $rows['ProductImageURL'];
             } else {
                 // If there isn't an array key for the category we're processing,
                 // then there isn't an array for this category, so create a new array,
                 $imageData[$categoryToProcess] = array();
                 // reset the index of the item we're processing to 1,
                 $categoryIndexToProcess = 1;
                 // and insert the image's url into that index
                 $imageData[$categoryToProcess][$categoryIndexToProcess] = "/images/" . $rows['ProductImageURL'];
             }
             // update the amount of items in the array of the category we're processing
             // to be the last index we processed
             $imageData[$categoryToProcess][0] = $categoryIndexToProcess;
             // update the amount of categories in the object to be the category we're processing
             // for the same reason as above
             $imageData[0] = $rows['CategoryID'];
             // process the next index
             $categoryIndexToProcess++;
         }
     }
     // close the database connection
     close_database_connection($connection);
     // return the imageData
     return $imageData;
 }
开发者ID:supermariolegend,项目名称:KBK,代码行数:55,代码来源:getImgFromDb.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP open_file函数代码示例发布时间:2022-05-15
下一篇:
PHP open_connection函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap