1 |
<?php |
2 |
|
3 |
/* |
4 |
----------------------------------- |
5 |
*** progressive media *** |
6 |
|
7 |
pm-dwdfl.inc |
8 |
Progressive Media: |
9 |
dynamic web data function library |
10 |
|
11 |
09.05.2k - 09.05.2k, pa |
12 |
----------------------------------- |
13 |
|
14 |
$Id: pm-dwdfl.php.inc,v 1.5 2001/01/29 01:01:03 amo Exp $ |
15 |
|
16 |
$Log: pm-dwdfl.php.inc,v $ |
17 |
Revision 1.5 2001/01/29 01:01:03 amo |
18 |
+ Schönheitskorrektur |
19 |
|
20 |
Revision 1.4 2001/01/11 23:36:41 amo |
21 |
+ Funktion 'DB_getRow' |
22 |
|
23 |
Revision 1.3 2000/12/11 20:58:09 amo |
24 |
+ module 'dwdfl_cfg' should be used too if using module 'dwdfl' |
25 |
|
26 |
Revision 1.2 2000/10/29 15:55:41 amo |
27 |
+ db_getSQLCriteriaString: gibt String aus wordlist-Array zurück, der einen Teil einer SQL-Verknüpfung ausmacht |
28 |
+ db_getFieldName_From_TableNameDotFieldName: gibt aus '<tabellenname>.<feldname>' '<feldname>' zurück |
29 |
|
30 |
Revision 1.1 2000/10/27 10:36:13 amo |
31 |
+ neu |
32 |
|
33 |
Revision 1.2 2000/10/09 22:42:20 amo |
34 |
no message |
35 |
|
36 |
|
37 |
----------------------------------- |
38 |
*/ |
39 |
|
40 |
DEFINE ('MODULE_DWDFL', 1); |
41 |
|
42 |
|
43 |
function Debug($text, $alert) { |
44 |
|
45 |
global $debug; |
46 |
|
47 |
if (($debug & 1) == 1) { |
48 |
|
49 |
echo "\n<p align=\"left\" style=\"font: 10 px Arial; color: #ffffc0; padding: 4 px; margin: 2 px; background-color: "; |
50 |
|
51 |
if ($alert) { echo "#800000"; } else { echo "#006000"; } |
52 |
|
53 |
echo ";\" width=\"66%\">\n<b>$text</b>\n</p>\n<br>\n\n"; |
54 |
|
55 |
} |
56 |
|
57 |
if (($debug & 2) == 2) { |
58 |
|
59 |
// LOG file schreiben. |
60 |
|
61 |
} |
62 |
|
63 |
} |
64 |
|
65 |
function ConnectDB($connection_pwd, $dbname) { |
66 |
|
67 |
global $dbc, $debug; |
68 |
|
69 |
if (!DEFINED ('MODULE_DWDFL_CFG')) { |
70 |
print "you should include 'pm-dwdfl_cfg.php.inc', too"; |
71 |
exit; |
72 |
} |
73 |
|
74 |
$dbpconn = mysql_pconnect($dbc[$connection_pwd]["hostname"], $dbc[$connection_pwd]["username"], $dbc[$connection_pwd]["password"]); |
75 |
$seldbresult = mysql_selectdb($dbname) . "<br>\n"; |
76 |
|
77 |
if ($dbpconn == 0) { |
78 |
|
79 |
Debug("Persistant database connection establish failed.<br>\n<br>\nMySQL: " . mysql_error() . ".<br>\n", true); |
80 |
|
81 |
} else { |
82 |
|
83 |
Debug("Persistant database connection established.<br>\n", false); |
84 |
|
85 |
} |
86 |
|
87 |
if ($seldbresult == 0) { |
88 |
|
89 |
Debug("Selection of database " . $dbname . " failed.<br>\n<br>\nMySQL: " . mysql_error() . ".<br>\n", true); |
90 |
|
91 |
} else { |
92 |
|
93 |
Debug("Database " . $dbname . " selected.<br>\n", false); |
94 |
|
95 |
} |
96 |
|
97 |
return $dbpconn; |
98 |
|
99 |
} // function ConnectDB |
100 |
|
101 |
function QueryDB($query) { |
102 |
|
103 |
$queryresult = mysql_query($query); |
104 |
|
105 |
if ($queryresult == 0) { |
106 |
|
107 |
Debug("Querying database failed.<br>\n<br>\nMySQL: " . mysql_error() . ".<br>\n", true); |
108 |
|
109 |
} else { |
110 |
|
111 |
Debug("Querying database was successful.<br>\n", false); |
112 |
|
113 |
} |
114 |
|
115 |
return $queryresult; |
116 |
|
117 |
} |
118 |
|
119 |
|
120 |
function DB_getRow($resultHandle) { |
121 |
|
122 |
if ($resultHandle) { |
123 |
return mysql_fetch_array($resultHandle); |
124 |
} |
125 |
|
126 |
} |
127 |
|
128 |
function db_getSQLCriteriaString($fieldname, $wordlist, $conclusionSQLOperator) { |
129 |
|
130 |
// patch: wenn kein Array als '$wordlist' übergeben wurde, machen wir ein's draus |
131 |
if (!is_array($wordlist)) { $wordlist = array ($wordlist); } |
132 |
|
133 |
$words = 0; |
134 |
$result = ''; |
135 |
for ($i = 0; $i < count($wordlist); $i++) { |
136 |
|
137 |
if(($cword = trim($wordlist[$i])) != '') { |
138 |
|
139 |
$sep = (($words++ > 0) ? (' ' . $conclusionSQLOperator . ' ') : ''); |
140 |
|
141 |
$result .= $sep . $fieldname . " LIKE '%$cword%'"; |
142 |
|
143 |
} |
144 |
|
145 |
} |
146 |
|
147 |
return $result; |
148 |
|
149 |
} |
150 |
|
151 |
function db_getFieldName_From_TableNameDotFieldName($givenString) { |
152 |
|
153 |
$myarr = split ('\.', $givenString); |
154 |
if (is_array($myarr)) { |
155 |
|
156 |
if (isset($myarr[1])) { return $myarr[1]; } |
157 |
|
158 |
} |
159 |
|
160 |
} |
161 |
|
162 |
?> |