本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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');
}