ADODB question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Karin J

    ADODB question

    I am in the process of converting a PHP5 script that talks to an MS
    SQL db from using ODBC to ADODB. I should say that I have no control
    over what is installed on the (remote) server. It seems to have some
    sort of minimal set of ADODB functions, but doesn't (for example)
    recognise the GetRow() function.

    Anyway, before, to put the results into an array for further
    manipulation, I had:
    $results = odbc_exec($conn ection_id, $select);
    while(odbc_fetc h_row($results, $rowcount)):
    $hits[]=array_map('tri m', odbc_fetch_arra y($results, $rowcount));
    endwhile;

    now I am trying things like:
    $results = $conn->execute($selec t); // (this works, and I can get
    individual values with: $results->Fields["Variable name"]->Value
    while (!$results->EOF):
    $hits[]=array_map('tri m', $results->fields );
    $results->MoveNext();
    endwhile;

    but get the error message
    "array_map( ) [function.array-map]: Argument #2 should be an array"
    I thought that $results->fields would be an array? Help!

    Many thanks

    Karin

    PS
    I also thought that
    foreach($result s AS $result):
    ...whatever...
    endforeach;
    would work, but this get the error message:
    "Uncaught exception 'Exception' with message 'Object of type variant
    did not create an Iterator'"

  • Erwin Moller

    #2
    Re: ADODB question

    Karin J wrote:
    I am in the process of converting a PHP5 script that talks to an MS
    SQL db from using ODBC to ADODB. I should say that I have no control
    over what is installed on the (remote) server. It seems to have some
    sort of minimal set of ADODB functions, but doesn't (for example)
    recognise the GetRow() function.
    >
    Anyway, before, to put the results into an array for further
    manipulation, I had:
    $results = odbc_exec($conn ection_id, $select);
    while(odbc_fetc h_row($results, $rowcount)):
    $hits[]=array_map('tri m', odbc_fetch_arra y($results, $rowcount));
    endwhile;
    >
    now I am trying things like:
    $results = $conn->execute($selec t); // (this works, and I can get
    individual values with: $results->Fields["Variable name"]->Value
    while (!$results->EOF):
    $hits[]=array_map('tri m', $results->fields );
    $results->MoveNext();
    endwhile;
    >
    but get the error message
    "array_map( ) [function.array-map]: Argument #2 should be an array"
    I thought that $results->fields would be an array? Help!
    Hi,

    In such cases, simply try this:
    <pre>
    <?php print_r($result s->fields); ?>
    </pre>

    Regards,
    Erwin Moller
    >
    Many thanks
    >
    Karin
    >
    PS
    I also thought that
    foreach($result s AS $result):
    ...whatever...
    endforeach;
    would work, but this get the error message:
    "Uncaught exception 'Exception' with message 'Object of type variant
    did not create an Iterator'"

    Comment

    • Karin J

      #3
      Re: ADODB question

      Erwin Moller wrote:
      Karin J wrote:
      >I am in the process of converting a PHP5 script that talks to an MS
      >SQL db from using ODBC to ADODB. I should say that I have no control
      >over what is installed on the (remote) server. It seems to have some
      >sort of minimal set of ADODB functions, but doesn't (for example)
      >recognise the GetRow() function.
      >>
      >Anyway, before, to put the results into an array for further
      >manipulation , I had:
      >$results = odbc_exec($conn ection_id, $select);
      >while(odbc_fet ch_row($results , $rowcount)):
      > $hits[]=array_map('tri m', odbc_fetch_arra y($results, $rowcount));
      >endwhile;
      >>
      >now I am trying things like:
      >$results = $conn->execute($selec t); // (this works, and I can get
      >individual values with: $results->Fields["Variable name"]->Value
      >while (!$results->EOF):
      > $hits[]=array_map('tri m', $results->fields );
      > $results->MoveNext();
      >endwhile;
      >>
      >but get the error message
      >"array_map( ) [function.array-map]: Argument #2 should be an array"
      >I thought that $results->fields would be an array? Help!
      >
      >
      Hi,
      >
      In such cases, simply try this:
      <pre>
      <?php print_r($result s->fields); ?>
      </pre>
      Hi Erwin
      This just prints the words "variant Object" !?
      Thanks
      Karin

      >Many thanks
      >>
      >Karin
      >>
      >>
      >PS
      >I also thought that
      >foreach($resul ts AS $result):
      > ...whatever...
      >endforeach;
      >would work, but this get the error message:
      >"Uncaught exception 'Exception' with message 'Object of type variant
      >did not create an Iterator'

      Comment

      • Erwin Moller

        #4
        Re: ADODB question

        Karin J wrote:
        Erwin Moller wrote:
        >Karin J wrote:
        >>I am in the process of converting a PHP5 script that talks to an MS
        >>SQL db from using ODBC to ADODB. I should say that I have no control
        >>over what is installed on the (remote) server. It seems to have some
        >>sort of minimal set of ADODB functions, but doesn't (for example)
        >>recognise the GetRow() function.
        >>>
        >>Anyway, before, to put the results into an array for further
        >>manipulatio n, I had:
        >>$results = odbc_exec($conn ection_id, $select);
        >>while(odbc_fe tch_row($result s, $rowcount)):
        >> $hits[]=array_map('tri m', odbc_fetch_arra y($results, $rowcount));
        >>endwhile;
        >>>
        >>now I am trying things like:
        >>$results = $conn->execute($selec t); // (this works, and I can get
        >>individual values with: $results->Fields["Variable name"]->Value
        >>while (!$results->EOF):
        >> $hits[]=array_map('tri m', $results->fields );
        >> $results->MoveNext();
        >>endwhile;
        >>>
        >>but get the error message
        >>"array_map( ) [function.array-map]: Argument #2 should be an array"
        >>I thought that $results->fields would be an array? Help!
        >>
        >>
        >Hi,
        >>
        >In such cases, simply try this:
        ><pre>
        ><?php print_r($result s->fields); ?>
        ></pre>
        >
        Hi Erwin
        This just prints the words "variant Object" !?
        Thanks
        Karin
        Hi Karin,

        Well, so you just proved PHP was complaining correctly it was not an array.
        If you are using COM objects, you are NOT using real PHP.
        So you must solve your problems inside your COM object's API.
        I cannot help there: it was many years ago since I last used that approach.
        Sorry.

        Good luck,
        Erwin Moller
        >
        >
        >>Many thanks
        >>>
        >>Karin
        >>>
        >>>
        >>PS
        >>I also thought that
        >>foreach($resu lts AS $result):
        >> ...whatever...
        >>endforeach;
        >>would work, but this get the error message:
        >>"Uncaught exception 'Exception' with message 'Object of type variant
        >>did not create an Iterator'

        Comment

        Working...