|
Revision 2, 1.2 kB
(checked in by sven, 3 years ago)
|
importing elgg-0.1.1a
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
// Generalised function to query the database |
|---|
| 6 |
// (returns an array of result rows) |
|---|
| 7 |
function db_query($sql_query) { |
|---|
| 8 |
global $querynum; |
|---|
| 9 |
global $querycache; |
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
return $querycache[$sql_query]; |
|---|
| 13 |
}*/ |
|---|
| 14 |
|
|---|
| 15 |
if (!isset($querynum)) { |
|---|
| 16 |
$querynum = 1; |
|---|
| 17 |
} else { |
|---|
| 18 |
$querynum++; |
|---|
| 19 |
} |
|---|
| 20 |
global $run_context; |
|---|
| 21 |
|
|---|
| 22 |
if ($sql_query != "") { |
|---|
| 23 |
|
|---|
| 24 |
if ($result = @mysql_query($sql_query)) { |
|---|
| 25 |
$data = array(); |
|---|
| 26 |
if (!is_bool($result)) { |
|---|
| 27 |
while ($row = @mysql_fetch_object($result)){ |
|---|
| 28 |
$data[] = $row; |
|---|
| 29 |
} |
|---|
| 30 |
} |
|---|
| 31 |
$querycache[$sql_query] = $data; |
|---|
| 32 |
return $data; |
|---|
| 33 |
} else { |
|---|
| 34 |
|
|---|
| 35 |
$querycache[$sql_query] = FALSE; |
|---|
| 36 |
return FALSE; |
|---|
| 37 |
} |
|---|
| 38 |
} else { |
|---|
| 39 |
return FALSE; |
|---|
| 40 |
} |
|---|
| 41 |
} |
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
function db_affected_rows() { |
|---|
| 45 |
return @mysql_affected_rows(); |
|---|
| 46 |
} |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
function db_id() { |
|---|
| 50 |
return @mysql_insert_id(); |
|---|
| 51 |
} |
|---|
| 52 |
|
|---|
| 53 |
?> |
|---|