both assoc and numeric indexes returned!

Help
2006-01-16
2013-04-11
  • Hello, these are my settings:
    /* for adodb_lite lib */
    $cx_ADOConn = &ADONewConnection('mysql','extend');
    $ADODB_FETCH_MODE = 'ADODB_FETCH_ASSOC';

    When I execute this query:
    $rows = &$cx_ADOConn->GetAssoc("SELECT userId, userName, regionId, sessionId, lastLogin, pw AS password, landingPageId, languageId, roleId FROM users $where");

    (It doesn't matter whether I use GetAssoc or GetAll)

    the results returned are:
    array(1) {
      [0]=>
      array(18) {
        [0]=>
        string(2) "14"
        ["userId"]=>
        string(2) "14"
        [1]=>
        string(10) "schellingw"
        ["userName"]=>
        string(10) "schellingw"
        [2]=>
        string(2) "17"
        ["regionId"]=>
        string(2) "17"
        [3]=>
        string(32) "71c77677ed8f2f0f44ae330918a2e120"
        ["sessionId"]=>
        string(32) "71c77677ed8f2f0f44ae330918a2e120"
        [4]=>
        string(19) "2006-01-15 19:45:00"
        ["lastLogin"]=>
        string(19) "2006-01-15 19:45:00"
        [5]=>
        string(32) "5f4dcc3b5aa765d61d8327deb882cf99"
        ["password"]=>
        string(32) "5f4dcc3b5aa765d61d8327deb882cf99"
        [6]=>
        NULL
        ["landingPageId"]=>
        NULL
        [7]=>
        string(2) "en"
        ["languageId"]=>
        string(2) "en"
        [8]=>
        string(1) "3"
        ["roleId"]=>
        string(1) "3"
      }
    }

    I only want to get associative indexes. There's not much of a performance improvement memory wise if I'm passing double the amount of data back and forth.

    The odd thing is that when I execute another query:
        $settings = &$cx_ADOConn->GetAssoc('SELECT setting,value FROM settings');

    I only get associative arrays returned.

    I would love to be able to move to adodb_lite, but can't do it if I'm getting both numeric and associative indexes returned.

    Am also breathlessly awaiting a small, simple caching module for those queries that are repeated on every page.

    Thanks for all your hard work. I'd love to hear your input.

     
    • Mark Dickenson
      Mark Dickenson
      2006-01-16

      You need to change this line...

      $ADODB_FETCH_MODE = 'ADODB_FETCH_ASSOC';

      to

      $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;

      You shouldn't quote that variable definition.

       
    • Mark Dickenson
      Mark Dickenson
      2006-01-16

      Oh, and you might want to think about enabling the extend module through the adodb.confg.php file instead of using the ADONewConnection('mysql','extend').