php/mysql puzzler

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I use the adodb_lite class and I'm getting curious results with a
wrapper function I've written to insert an array in a table. The
function has an optional parameter to verify columns (the array keys)
before executing the statement.  It runs this statement:


(I've added a larger code snippet below.)

What is weird is that if I call the function more than once, this part
of it will fail after the first call.

What is weirder is that it works fine on my local server -- I only get
the problem on my host's server.

Anyone encounter a problem like this?  One solution would be just to
skip the column verification.  But I suspect its symptomatic of some
php or mysql setting that may have unintended consequence elsewhere.

I should note that adodb_lite is called using a singleton pattern, so
that the same object should be used each time this function is called.
Could that have something to do with it?  Also my host is PHP 4 and my
local server PHP 5 (and may be using different versions of MySQL as

Any help will be appreciated.  If you think this is a question better
aimed at the mysql discussion group, let me know and I'll try there.


Code Snippet:

// Get DB Object
$_ADOcx = amvc_ado_cx($db_name);

// Set Fetch Mode

// Check Table Columns
if ( $_FLAG['check_cols'] )
  // SQL Query
  $_SQL['check_cols'] = "SHOW COLUMNS FROM `$table`";

  // Run Query
  if ( !$_ADO_r = $_ADOcx->Execute($_SQL['check_cols']) )
      trigger_error("unable to check columns for table [$table]:
      return 0;

  // Sanity Check
  if ( !$_ADO_r->RecordCount() )
      trigger_error("No record count for table [$table]",
      return 0;

It fails right here, on the RecordCount (but only after first call.)

Re: php/mysql puzzler

Aha!  In the course of writing out my problem here (below), I noted the
different versions of PHP my server and my host's server were using.
This was the first time I had taken note of it myself.

Right after this, I changed my code so that it called the adodb_lite
class by reference ( =& ).  That solved it.  This note on the PHP site
confirms it:

Anyway, if nothing else, this speaks to the power of articulating your
problem when nothing else seems to be working.

Quoted text here. Click to load it

Site Timeline