CVS update: php3/tests
| From: | danny | Date: | Sun, 16 Aug 1998 14:50:46 +0000 |
| Subject: | CVS update: php3/tests | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-273@lists.php.net to get a copy of this message | ||
Date: Sunday August 16, 1998 @ 10:50
Author: danny
Update of /repository/php3/tests
In directory asf:/tmp/cvs-serv4955/tests
Modified Files:
informix.php3
Log Message:
1. ifx_affected_rows($resultid) now returns :
- the estimated number of rows for select statements
- the real number of rows for insert/update/delete statements
2. some minor corrections
3. added ifx_prepare : prepares a query, sets affected_rows
4. added ifx_do : executes (or opens cursor for) a previously
prepared query, sets affected rows for execute-immediate queries
Index: php3/tests/informix.php3
diff -c php3/tests/informix.php3:1.1 php3/tests/informix.php3:1.2
*** php3/tests/informix.php3:1.1 Sat Aug 15 13:51:34 1998
--- php3/tests/informix.php3 Sun Aug 16 10:50:45 1998
***************
*** 11,20 ****
$res = ifx_connect("stores7@demo_se","informix","informix");
if (!check_ifx($res)) {
! printf("ifx_connect : %s %s<br>\n", ifx_error($res), ifx_errormsg());
}
if (! $res) {
! printf("can not connect to server<br>\n");
exit;
}
printf("+----------------------------------------+\n");
--- 11,20 ----
$res = ifx_connect("stores7@demo_se","informix","informix");
if (!check_ifx($res)) {
! printf("ifx_connect : %s %s\n", ifx_error($res), ifx_errormsg());
}
if (! $res) {
! printf("can not connect to server\n");
exit;
}
printf("+----------------------------------------+\n");
***************
*** 23,35 ****
$query = "select * from orders";
$result = ifx_query($query, $res, "scroll");
if (!check_ifx($res)) {
! printf("ifx_query : %s:%s <br>\n", ifx_error($res), ifx_errormsg());
}
if (! $result) {
! printf("ifx_query : bailing out<br> \n");
die;
}
printf("+----------------------------------------+\n");
printf("| Number of columns : |\n");
printf("+----------------------------------------+\n");
--- 23,39 ----
$query = "select * from orders";
$result = ifx_query($query, $res, "scroll");
if (!check_ifx($res)) {
! printf("ifx_query : %s:%s \n", ifx_error($res), ifx_errormsg());
}
if (! $result) {
! printf("ifx_query : bailing out \n");
die;
}
printf("+----------------------------------------+\n");
+ printf("| affected rows : |\n");
+ printf("+----------------------------------------+\n");
+ printf("Estimated number of rows : %d\n\n", ifx_affected_rows($result));
+ printf("+----------------------------------------+\n");
printf("| Number of columns : |\n");
printf("+----------------------------------------+\n");
***************
*** 93,108 ****
for(reset($row); $fname = key($row); next($row)) {
printf("%s=%s;", $fname, $row[$fname]);
}
! printf("\n");
printf("+-----------------------------------------+\n");
! printf("| -------- end --------- |\n");
printf("+-----------------------------------------+\n");
unset($row);
! ifx_free_result($row);
ifx_close($res);
</script>
--- 97,247 ----
for(reset($row); $fname = key($row); next($row)) {
printf("%s=%s;", $fname, $row[$fname]);
}
! printf("\n\nResultid was : %d\n",$result);
! ifx_free_result($result);
!
! printf("\n\n\n********* and now prepare/do test *******\n\n\n");
!
! printf("+----------------------------------------+\n");
! printf("| prepare query : 'select * from orders' |\n");
! printf("+----------------------------------------+\n");
! $query = "select * from orders";
! $result = ifx_prepare($query, $res, "scroll");
! if (!check_ifx($res)) {
! printf("ifx_prepare : %s:%s \n", ifx_error($res), ifx_errormsg());
! }
! if (! $result) {
! printf("ifx_prepare : bailing out \n");
! die;
! }
! printf("+----------------------------------------+\n");
! printf("| affected rows : |\n");
! printf("+----------------------------------------+\n");
! printf("Estimated number of rows : %d\n\n", ifx_affected_rows($result));
! printf("+----------------------------------------+\n");
! printf("| Number of columns : |\n");
! printf("+----------------------------------------+\n");
!
! printf("Number of columns = %d\n", ifx_num_fields($result));
!
! printf("+----------------------------------------+\n");
! printf("| field types and properties : |\n");
! printf("+----------------------------------------+\n");
!
! unset($types);
! unset($props);
! $types = ifx_fieldtypes($result);
! $props = ifx_fieldproperties($result);
! if ((! isset($types)) || (! isset($props))) {
! printf("ifx_fieldxxxx : %s\n", ifx_error($res));
! ifx_close($res);
! die;
! }
! for ($i = 0; $i < count($types); $i++) {
! $fname = key($types);
! printf("%s :\t type = %s\n", $fname, $types[$fname]);
! printf("%s :\t properties = %s\n", $fname, $props[$fname]);
! next($types);
! next($props);
! }
! printf("+----------------------------------------+\n");
! printf("| execute query : 'select * from orders' |\n");
! printf("+----------------------------------------+\n");
! if (! ifx_do($result)) {
! printf("ifx_query : %s:%s \n", ifx_error($res), ifx_errormsg());
! printf("ifx_do : bailing out\n");
! die;
! }
! printf("+----------------------------------------+\n");
!
! // the quick way :
! // ifx_htmltbl_result($result,"border=\"1\"");
!
! // with more user control :
! printf("+----------------------------------------+\n");
! printf("| in normal order : |\n");
! printf("+----------------------------------------+\n");
! unset($row);
! $row = ifx_fetch_row($result, "first");
! while (is_array($row)) {
! for(reset($row); $fname = key($row); next($row)) {
! printf("%s=%s;", $fname, $row[$fname]);
! }
! printf("\n");
! $row = ifx_fetch_row($result, "next");
! }
! printf("+----------------------------------------+\n");
! printf("| and now in reverse order : |\n");
! printf("+----------------------------------------+\n");
! unset($row);
! $row = ifx_fetch_row($result, "last");
! while (is_array($row)) {
! for(reset($row); $fname = key($row); next($row)) {
! printf("%s=%s;", $fname, $row[$fname]);
! }
! printf("\n");
! $row = ifx_fetch_row($result, "previous");
! }
!
printf("+-----------------------------------------+\n");
! printf("| and now row number 10 |\n");
printf("+-----------------------------------------+\n");
unset($row);
+ $row = ifx_fetch_row($result, 10);
+ for(reset($row); $fname = key($row); next($row)) {
+ printf("%s=%s;", $fname, $row[$fname]);
+ }
+ printf("\n");
+ unset($row);
+
+ printf("\n\nResultid was : %d\n",$result);
+ ifx_free_result($result);
+
+ printf("\n");
+ printf("+-----------------------------------------+\n");
+ printf("| some execute immediates |\n");
+ printf("+-----------------------------------------+\n");
+ $query = "create table testdh (k serial, d char(100), primary key (k))";
+ $result = ifx_prepare($query, $res);
+ if (!check_ifx($res)) {
+ printf("ifx_prepare : %s:%s \n", ifx_error($res), ifx_errormsg());
+ }
+ if (! $result) {
+ printf("ifx_prepare : bailing out \n");
+ die;
+ }
+ printf("create table successfully prepared\n");
+ if (! ifx_do($result)) {
+ printf("ifx_query : %s:%s \n", ifx_error($res), ifx_errormsg());
+ printf("ifx_do : bailing out\n");
+ die;
+ }
+ printf("create table successfully executed\n");
+ ifx_free_result($result);
! $query = "drop table testdh";
! $result = ifx_prepare($query, $res);
! if (!check_ifx($res)) {
! printf("ifx_prepare : %s:%s \n", ifx_error($res), ifx_errormsg());
! }
! if (! $result) {
! printf("ifx_prepare : bailing out \n");
! die;
! }
! printf("drop table successfully prepared\n");
! if (! ifx_do($result)) {
! printf("ifx_query : %s:%s \n", ifx_error($res), ifx_errormsg());
! printf("ifx_do : bailing out\n");
! die;
! }
! printf("drop table successfully executed\n");
! ifx_free_result($result);
ifx_close($res);
+ printf("+-----------------------------------------+\n");
+ printf("| -------- end --------- |\n");
+ printf("+-----------------------------------------+\n");
</script>
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net