57
التفاعل مع قواعد بيانات متعددة
النص 1-3 البرمجي dbx_urls.php
1.
<html>
2.
<head>
3.
4.
5.
6.
<title>A PHP-DBX URL Organizer</title>
<style type=text/css>
p, ul, td, h1, h2, h3 {font-family: verdana, helvetica, sans-serif;}
</style>
7.
</head>
8.
<body>
9.
<?
10.
/*****
11.
TABLE DEFINITION FOR THIS EXAMPLE:
12.
13.
url VARCHAR(128) not null,
14.
create table URLS (
description TEXT,
15. primary key (url));
16.
*****/
17. //define $MODULE as DBX_MYSQL, DBX_MSSQL, DBX PGSQL, or your supported database
18. $MODULE = DBX_PGSQL;
19. $server = "192.168.0.5";
$user = "psqluser";
$password = "password";
$database = "php";
/* FUNCTIONS */
function get_urls ($dbconn, $sql) {
$result = @dbx_query($dbconn, $sql);
if( $result == 0 ) {
echo dbx_error($dbconn);
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
}
31.
}
32.
33.
34.
$sql
35.
} else {
return $result;
function url($action, $dbconn, $url, $description) {
if ($action == "add") {
= "insert into URLS values ('$url',
}elseif ($action == "delete")
'$description')";
ص٥٧