Forums

PHP

This topic is locked

Problems with PHAkT

Posted 01 Oct 2001 11:38:25
1
has voted
01 Oct 2001 11:38:25 xiao biao posted:
I use PHAkT in UltraDev.When I create a RecordSet to connect a database,use test to view result is ok.But I create a dynamic list with this Recordset,the list display is null,not anything value to display. My example code is this:
----------------------------------------------------------------

<?php


// Copyright (c) Interakt Online 2001
// www.interakt.ro/

require("./adodb/adodb.inc.php";
require("./Connections/Test.php";
?><?php
$Recordset1=$Test->Execute("SELECT * FROM EMPLOYEES" or DIE($Test->ErrorMsg());
$Recordset1_numRows=0;
$Recordset1__totalRows=$Recordset1->RecordCount();
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<form name="form2" method="post" action="">
<p>
<select name="select" size="1">
<?php
if ($Recordset1__totalRows > 0){
$Recordset1__index=0;
$Recordset1->MoveFirst();
WHILE ($Recordset1__index < $Recordset1__totalRows){
?>
<OPTION VALUE="<?php echo $Recordset1->Fields("FIRSTNAME"?>">
<?php echo $Recordset1->Fields("FIRSTNAME";?>
</OPTION>
<?php
$Recordset1->MoveNext();
$Recordset1__index++;
}
$Recordset1__index=0;
$Recordset1->MoveFirst();
}
?>
</select>
</p>
<?
$total=$Recordset1->RecordCount();
echo $total;
?>
</form>
<form name="form1" method="post" action="">
</form>
</body>
</html>
<?php
$Recordset1->Close();
?>

---------------------------------------------------------------------------
I check the $Recordset1->RecordCount() value is incorrect,is's alway is -1.I think this is a reason to cause the problem.I testing with Access,Oracle all has this problem.Help me
please! <BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote> <hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Replies

Replied 01 Oct 2001 14:33:40
01 Oct 2001 14:33:40 Tim Green replied:
Unfortunately their is presently a known issue with the ADODB libraries that causes Oracle (and some other DB's) to return -1 for the record count.

Because of this you have to employ a workaround within the recordset script to get it all working correctly.

After the block containing:-

<pre id=code><font face=courier size=2 id=code>
$Recordset1=$Test-&gt;Execute("SELECT * FROM EMPLOYEES" or DIE($Test-&gt;ErrorMsg());
$Recordset1_numRows=0;
$Recordset1__totalRows=$Recordset1-&gt;RecordCount();
</font id=code></pre id=code>

Enter the following, as a separate PHP code block:-

<pre id=code><font face=courier size=2 id=code>
$rsCount = $Test-&gt;Execute("SELECT COUNT(*) AS TotRows FROM EMPLOYEES" or DIE($Test-&gt;ErrorMsg());
$Recordset1__totalRows = $rsCount-&gt;Fields("TotRows";
</font id=code></pre id=code>

Tim Green

Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 01 Oct 2001 15:45:00
01 Oct 2001 15:45:00 xiao biao replied:
I testing it is ok!Thank you very much!!You are a good man!!!

Reply to this topic