Вы не зарегистрированы? Нажмите здесь для регистрации.
Забыли пароль? Запросите новый здесь.
|
Вы должны авторизироваться, чтобы добавить сообщение.
|
|
|
Последние активные темы форума |
|
sesam_diagnostic
(PHP 3 CVS only) sesam_diagnostic --
Return status information for last SESAM call
Descriptionarray sesam_diagnostic ( void ) Returns an associative array of status and return codes for the
last SQL query/statement/command. Elements of the array are:
Таблица 1.
Status information returned by sesam_diagnostic()
Element | Contents |
---|
$array["sqlstate"] | 5 digit SQL return code (see the SESAM manual for the
description of the possible values of SQLSTATE)
| $array["rowcount"] | number of affected rows in last update/insert/delete (set
after "immediate" statements only)
| $array["errmsg"] | "human readable" error message string (set after errors
only)
| $array["errcol"] | error column number of previous error (0-based; or -1 if
undefined. Set after errors only)
| $array["errlin"] | error line number of previous error (0-based; or -1 if
undefined. Set after errors only)
|
In the following example, a syntax error (E SEW42AE ILLEGAL
CHARACTER) is displayed by including the offending SQL statement
and pointing to the error location:
Пример 1. Displaying SESAM error messages with error position
<?php
// Function which prints a formatted error message,
// displaying a pointer to the syntax error in the
// SQL statement
function
PrintReturncode
(
$exec_str
)
{
$err
=
Sesam_Diagnostic
();
$colspan
=
4
;
// 4 cols for: sqlstate, errlin, errcol, rowcount
if (
$err
[
"errlin"
] == -
1
)
--
$colspan
;
if (
$err
[
"errcol"
] == -
1
)
--
$colspan
;
if (
$err
[
"rowcount"
] ==
0
)
--
$colspan
;
echo
"<table border=\"1\">\n"
;
echo
"<tr><th colspan=\""
.
$colspan
.
"\"><span class=\"spanred\">ERROR:</span> "
.
htmlspecialchars
(
$err
[
"errmsg"
]) .
"</th></tr>\n"
;
if (
$err
[
"errcol"
] >=
0
) {
echo
"<tr><td colspan=\""
.
$colspan
.
"\"><pre>\n"
;
$errstmt
=
$exec_str
.
"\n"
;
for (
$lin
=
0
;
$errstmt
!=
""
; ++
$lin
) {
if (
$lin
!=
$err
[
"errlin"
]) {
// $lin is less or greater than errlin
if (!(
$i
=
strchr
(
$errstmt
,
"\n"
)))
$i
=
""
;
$line
=
substr
(
$errstmt
,
0
,
strlen
(
$errstmt
)-
strlen
(
$i
)+
1
);
$errstmt
=
substr
(
$i
,
1
);
if (
$line
!=
"\n"
)
echo
htmlspecialchars
(
$line
);
} else {
if (! (
$i
=
strchr
(
$errstmt
,
"\n"
)))
$i
=
""
;
$line
=
substr
(
$errstmt
,
0
,
strlen
(
$errstmt
)-
strlen
(
$i
)+
1
);
$errstmt
=
substr
(
$i
,
1
);
for (
$col
=
0
;
$col
<
$err
[
"errcol"
]; ++
$col
) {
echo (
substr
(
$line
,
$col
,
1
) ==
"\t"
) ?
"\t"
:
"."
;
}
echo
"<span class=\"spanred\">\\</span>\n"
;
echo
"<span class=\"normal\">"
.
htmlspecialchars
(
$line
) .
"</span>"
;
for (
$col
=
0
;
$col
<
$err
[
"errcol"
]; ++
$col
) {
echo (
substr
(
$line
,
$col
,
1
) ==
"\t"
) ?
"\t"
:
"."
;
}
echo
"<span class=\"spanred\">/</span>\n"
;
}
}
echo
"</pre></td></tr>\n"
;
}
echo
"<tr>\n"
;
echo
" <td>sqlstate="
.
$err
[
"sqlstate"
] .
"</td>\n"
;
if (
$err
[
"errlin"
] != -
1
)
echo
" <td>errlin="
.
$err
[
"errlin"
] .
"</td>\n"
;
if (
$err
[
"errcol"
] != -
1
)
echo
" <td>errcol="
.
$err
[
"errcol"
] .
"</td>\n"
;
if (
$err
[
"rowcount"
] !=
0
)
echo
" <td>rowcount="
.
$err
[
"rowcount"
] .
"</td>\n"
;
echo
"</tr>\n"
;
echo
"</table>\n"
;
}
if (!
sesam_connect
(
"mycatalog"
,
"phoneno"
,
"otto"
))
die (
"cannot connect"
);
$stmt
=
"SELECT * FROM phone\n"
.
" WHERE@ LASTNAME='KRAEMER'\n"
.
" ORDER BY FIRSTNAME"
;
if (!(
$result
=
sesam_query
(
$stmt
)))
PrintReturncode
(
$stmt
);
?>
|
|
Смотрите также: sesam_errormsg() for simple access
to the error string only
|
· Гостей: 18
· Пользователей: 0
· Всего пользователей: 453
· Новый пользователь: ZDA
|
|