[Vtigercrm-developers] adodb version
Adam Heinz
amh at metricwise.net
Thu Jul 12 13:53:28 PDT 2012
TLDR: Made some progress on getting ADOdb+PDO working, but
PearDatabase->query_result is problematic.
After a long delay, I have spent some more time trying to get PDO
running beneath ADOdb. I've determined that the source of my earlier
weirdness is the PearDatabase->query_result function. That function
calls ADORecordSet->FetchRow, which "internally moves to the next
record after returning the current row" [1]. This means that logic
like [2]
$fieldcolname = $adb->query_result($result1,$i,"columnname");
$tablename = $adb->query_result($result1,$i,"tablename");
$fieldname = $adb->query_result($result1,$i,"fieldname");
repeatedly traverses between the $i and $i+1 rows of a result set as
it pulls fields one at a time. Ignoring efficiency, what I'm seeing
is that at some point, it just stops working. When logging in, the
Users module loaded its 40 fields and was processing each of them just
fine -- until at some point it just stopped working. I saw the
query_result call for columnname succeed, then the subsequent call for
tablename fail. Perhaps a little more telling, it failed on the 14th
field, 2nd query_result call... 13 * 3 + 2 = 41; one traversal more
than the number of rows in the record set.
When I replaced the above code with
$rowdata = $adb->query_result_rowdata($result1,$i);
$fieldcolname = $rowdata["columnname"];
$tablename = $rowdata["tablename"];
$fieldname = $rowdata["fieldname"];
it succeeds for all 40 rows. I am successfully logged in now, but
seeing similar weirdness in various other parts of the CRM. I think
in order to get PDO reliably working, there is going to have to be
some sort of mass repair of the 2,700 uses of query_result. I'm not a
fan of that function anyway, as its to_html call prevents me from
using it for XML generation.
Attaching my current patch.
[1] http://phplens.com/lens/adodb/docs-adodb.htm#fetchrow
[2] http://trac.vtiger.com/cgi-bin/trac.cgi/browser/vtigercrm/branches/5.4.0/modules/Users/Users.php#L936
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pdo.patch
Type: application/octet-stream
Size: 2108 bytes
Desc: not available
Url : http://lists.vtigercrm.com/pipermail/vtigercrm-developers/attachments/20120712/cbc19cd4/attachment.obj
More information about the vtigercrm-developers
mailing list