|
|
PHP (angielski akronim rekurencyjny, którego rozwinięcie to PHP Hypertext Preprocessor), pierwotnie nazwany Personal
Home Page - skryptowy język programowania, służący przede wszystkim do tworzenia dynamicznych stron WWW i wykonywany w
tym przypadku po stronie serwera, z możliwością zagnieżdżania w HTML (bądź XHTML). PHP jest podobny w założeniach do
dużo starszego mechanizmu SSI (Server Side Includes), jednak jest w stosunku do SSI nieporównanie bardziej rozbudowany.
Udostępniany jest na zasadach licencji open-source. Jego składnia bazuje na językach C, Java i Perl.
SQL (ang. Structured Query Language) to strukturalny język zapytań używany do tworzenia, modyfikowania baz danych oraz
do umieszczania i pobierania danych z baz danych.
Język SQL jest językiem deklaratywnym. Decyzję o sposobie przechowywania i pobrania danych pozostawia się systemowi
zarządzania bazą danych DBMS.
Jest to język programowania opracowany w latach siedemdziesiątych w firmie IBM. Stał się on standardem w komunikacji z
serwerami relacyjnych baz danych. Wiele współczesnych systemów relacyjnych baz danych używa do komunikacji z
użytkownikiem SQL, dlatego mówi się, że korzystanie z relacyjnych baz danych, to korzystanie z SQL-a.
Apache jest otwartym serwerem HTTP dostępnym dla wielu systemów operacyjnych (m.in. UNIX, GNU/Linux, BSD,
Microsoft Windows). Po angielsku słowo Apache wymawia się epaczi, co brzmi tak samo jak a patchy (server), co było
określeniem tego serwera we wczesnym stadium jego rozwoju w 1995 roku, kiedy był on głównie zbiorem poprawek (patch)
nałożonych na serwer HTTP o nazwie NCSA.
Apache jest najszerzej stosowanym serwerem HTTP w Internecie. W maju 2003 jego udział wśród serwerów wynosił 62%. W
połączeniu z interpreterem języka skryptowego PHP i bazą danych MySQL, Apache stanowi jedno z najczęściej spotykanych
środowisk w firmach oferujących miejsce na serwerach sieciowych.
|
sesam_query
(PHP 3 CVS only) sesam_query -- Perform a SESAM SQL query
and prepare the result
Descriptionstring sesam_query ( string query [, bool scrollable]
)
Returns: A SESAM "result identifier" on success, or
FALSE on error.
A "result_id" resource is used by other functions to
retrieve the query results.
sesam_query() sends a query to the
currently active database on the server. It can execute both
"immediate" SQL statements and "select type" queries. If an
"immediate" statement is executed, then no cursor is allocated,
and any subsequent sesam_fetch_row() or sesam_fetch_result() call will return an
empty result (zero columns, indicating end-of-result). For
"select type" statements, a result descriptor and a (scrollable
or sequential, depending on the optional boolean scrollable parameter) cursor will be
allocated. If scrollable is
omitted, the cursor will be sequential.
When using "scrollable" cursors, the cursor can be freely
positioned on the result set. For each "scrollable" query,
there are global default values for the scrolling type
(initialized to: SESAM_SEEK_NEXT)
and the scrolling offset which can either be set once by
sesam_seek_row() or each time when fetching
a row using sesam_fetch_row().
For "immediate" statements, the number of affected rows is
saved for retrieval by the sesam_affected_rows() function.
See also: sesam_fetch_row() and sesam_fetch_result().
Przykład 1. Show all rows of the "phone" table as
a HTML table
<?php if (!sesam_connect("phonedb", "demo", "otto"))
die("cannot connect");
$result = sesam_query("select * from phone");
if (!$result) {
$err = sesam_diagnostic();
die ($err["errmsg"]);
}
echo "<table border>\n";
// Add title header with column names above the result:
if ($cols = sesam_field_array($result)) {
echo "<tr><th colspan=" . $cols["count"] . ">Result:</th></tr>\n";
echo "<tr>\n";
for ($col = 0; $col < $cols["count"]; ++$col) {
$colattr = $cols[$col];
/* Span the table head over SESAM's "Multiple Fields": */
if ($colattr["count"] > 1) {
echo "<th colspan=\"" . $colattr["count"] . "\">" . $colattr["name"] .
"(1.." . $colattr["count"] . ")</th>\n";
$col += $colattr["count"] - 1;
} else
echo "<th>" . $colattr["name"] . "</th>\n";
}
echo "</tr>\n";
}
do {
// Fetch the result in chunks of 100 rows max.
$ok = sesam_fetch_result($result, 100);
for ($row=0; $row < $ok["rows"]; ++$row) {
echo " <tr>\n";
for ($col = 0; $col < $ok["cols"]; ++$col) {
if (isset($ok[$col][$row])) {
echo "<td>" . $ok[$col][$row] . "</td>\n";
} else {
echo "<td>-empty-</td>\n";
}
}
echo "</tr>\n";
}
} while ($ok["truncated"]); // while there may be more data
echo "</table>\n";
// free result id sesam_free_result($result);
?> |
|
|