Hi there,
We have recently changed servers and I am having a problem getting php to return results from MySql using the PEAR adodb extension.
PhpMyAdmin connects and returns results fine and I can even go to a SQL box, type in some SQL and get a result back.
However, when I write my own php it connects but the return value from the query is null and I get an error when I try to return FetchRow() from it.
Interestingly the Exception is NOT called.
PHP Code:
include("adodb/adodb.inc.php");
$DB_Test = &NewADOConnection('mysql');
$DB_Test->PConnect("localhost","username", "password", "db");
$sql = "
SELECT
MAX(id) as max_id
FROM
table
";
try
{
$result = $DB_Test->Execute($sql);
$row = $result->FetchRow();
$table_id = $row["max_id"];
}
catch(Exception $e)
{
echo($e->getMessage());
}
echo($table_id);
When I do print_r on $DB_Test it seems to be populated OK
Code:
[databaseType] => mysql
[dataProvider] => mysql
[hasInsertID] => 1
[hasAffectedRows] => 1
[metaTablesSQL] => SHOW TABLES
[metaColumnsSQL] => SHOW COLUMNS FROM `%s`
[fmtTimeStamp] => 'Y-m-d H:i:s'
[hasLimit] => 1
[hasMoveFirst] => 1
[hasGenID] => 1
[isoDates] => 1
[sysDate] => CURDATE()
[sysTimeStamp] => NOW()
[hasTransactions] =>
[forceNewConnect] =>
[poorAffectedRows] => 1
[clientFlags] => 0
[substr] => substring
[nameQuote] => `
[compat323] =>
[_genIDSQL] => update %s set id=LAST_INSERT_ID(id+1);
[_genSeqSQL] => create table %s (id int not null)
[_genSeqCountSQL] => select count(*) from %s
[_genSeq2SQL] => insert into %s values (%s)
[_dropSeqSQL] => drop table %s
[database] => ivimeds
[host] => localhost
[user] => masteruser
[password] => masteruser
[debug] =>
[maxblobsize] => 262144
[concat_operator] => +
[length] => length
[random] => rand()
[upperCase] => upper
[fmtDate] => 'Y-m-d'
[true] => 1
[false] => 0
[replaceQuote] => \'
[charSet] =>
[metaDatabasesSQL] =>
[uniqueOrderBy] =>
[emptyDate] =>
[emptyTimeStamp] =>
[lastInsID] =>
[hasTop] =>
[readOnly] =>
[genID] => 0
[raiseErrorFn] =>
[cacheSecs] => 3600
[memCache] =>
[memCacheHost] =>
[memCachePort] => 11211
[memCacheCompress] =>
[arrayClass] => ADORecordSet_array
[noNullStrings] =>
[numCacheHits] => 0
[numCacheMisses] => 0
[pageExecuteCountRows] => 1
[uniqueSort] =>
[leftOuter] =>
[rightOuter] =>
[ansiOuter] =>
[autoRollback] =>
[fnExecute] =>
[fnCacheExecute] =>
[blobEncodeType] =>
[rsPrefix] => ADORecordSet_
[autoCommit] => 1
[transOff] => 0
[transCnt] => 0
[fetchMode] =>
[null2null] => null
[_oldRaiseFn] =>
[_transOK] =>
[_connectionID] => Resource id #7
[_errorMsg] =>
[_errorCode] =>
[_queryID] =>
[_isPersistentConnection] => 1
[_bindInputArray] =>
[_evalAll] =>
[_affected] =>
[_logsql] =>
[_transmode] =>
[databaseName] => ivimeds
Is there anything missing from the $DB_Object? has anyone come across this before?
The versions I am using are:
PHP Version: 5.2.10
MySQL Server version: 5.0.89-community
Andrew.