By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,962 Members | 1,998 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,962 IT Pros & Developers. It's quick & easy.

ADODB question

P: n/a
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($connection_id, $select);
while(odbc_fetch_row($results, $rowcount)):
$hits[]=array_map('trim', odbc_fetch_array($results, $rowcount));
endwhile;

now I am trying things like:
$results = $conn->execute($select); // (this works, and I can get
individual values with: $results->Fields["Variable name"]->Value
while (!$results->EOF):
$hits[]=array_map('trim', $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($results 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'"

May 16 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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($connection_id, $select);
while(odbc_fetch_row($results, $rowcount)):
$hits[]=array_map('trim', odbc_fetch_array($results, $rowcount));
endwhile;

now I am trying things like:
$results = $conn->execute($select); // (this works, and I can get
individual values with: $results->Fields["Variable name"]->Value
while (!$results->EOF):
$hits[]=array_map('trim', $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($results->fields); ?>
</pre>

Regards,
Erwin Moller
>
Many thanks

Karin

PS
I also thought that
foreach($results 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'"
May 16 '07 #2

P: n/a
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($connection_id, $select);
while(odbc_fetch_row($results, $rowcount)):
$hits[]=array_map('trim', odbc_fetch_array($results, $rowcount));
endwhile;

now I am trying things like:
$results = $conn->execute($select); // (this works, and I can get
individual values with: $results->Fields["Variable name"]->Value
while (!$results->EOF):
$hits[]=array_map('trim', $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($results->fields); ?>
</pre>
Hi Erwin
This just prints the words "variant Object" !?
Thanks
Karin

>Many thanks

Karin
PS
I also thought that
foreach($results 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'
May 17 '07 #3

P: n/a
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
manipulation, I had:
$results = odbc_exec($connection_id, $select);
while(odbc_fetch_row($results, $rowcount)):
$hits[]=array_map('trim', odbc_fetch_array($results, $rowcount));
endwhile;

now I am trying things like:
$results = $conn->execute($select); // (this works, and I can get
individual values with: $results->Fields["Variable name"]->Value
while (!$results->EOF):
$hits[]=array_map('trim', $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($results->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($results 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'
May 17 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.