Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder Stooshie's Avatar
    Join Date
    Mar 2008
    Location
    Dundee, Scotland
    Posts
    378
    Thanks
    9
    Thanked 39 Times in 39 Posts

    Question php mysql using PEAR adodb connecting but returning null ressult

    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.
    Regards, Stooshie
    O

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,567
    Thanks
    78
    Thanked 4,385 Times in 4,350 Posts
    Well, not to ask a silly question...

    I have no idea what PEAR is, but if it uses Microsoft's ADODB, then I assume this is intended for a Windows server, yes?

    And if that is so, then have you installed MyODBC to connect MySQL to ADODB?
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Regular Coder Stooshie's Avatar
    Join Date
    Mar 2008
    Location
    Dundee, Scotland
    Posts
    378
    Thanks
    9
    Thanked 39 Times in 39 Posts
    Hi there,

    PEAR is a collection of PHP extensions.

    The adodb is an extension which allows you to connect to many different types of database. It is written in PHP and can be run on any server using PHP. Our server is *nix.

    It works on our old server so I am trying to find out what settings could be different and nothing except some very minor PHP and MySQL upgrades (e.g. PHP 5.2.10 rather than 5.2.6).
    Regards, Stooshie
    O

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,567
    Thanks
    78
    Thanked 4,385 Times in 4,350 Posts
    Fascinating. They use the same acronym the MS uses. "ADODB". Wonder what it stands for in PEAR? ("ActiveX Data Objects" or something like that with MS.)
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •