[SOLVED] PHP button - cannot use object of type ADORecordSet_mysqlt as array

I want to check something in database and then write something into it (or not).
So I’m trying this code:


$check_table = 'table1';    // Table name
$check_where = "column1 = '1'"; // Where clause

// Check for record
$check_sql = "SELECT column2, cloumn3 FROM $check_table WHERE $check_where";
sc_select(rs, $check_sql);

if (isset({rs[0][0]}))     // Row found
{
   $other_field = {rs[0][0]};
   $other_region = {rs[0][1]};
	
   echo "<br>found: $other_field and $other_region<br>";
}
else     // No row found
{
   echo "<br>not found<br>";
}

And the result is this:

Fatal error: Cannot use object of type ADORecordSet_mysqlt as array in /opt/NetMake/v7/wwwroot/scriptcase/app/test/test1/test1_form_apl.php on line 1837

As you can see this is taken from standard SC example and of course works quite well if put in any Event.

Use sc_lookup() instead of sc_select(). The arrays returned are quite different.

jsb

Works!
Are you kind of Angel jsb? :wink:

BTW - isn’t it a bug anyway?

BTW - isn’t it a bug anyway?

no it isn’t. The select returns a cursor to a record while the lookup returns an array of all values.

If you say so I belive.
But I can’t see any reason why it shouldn’t work in PHPbutton but works somewhere else.
Whatever.
It’s great that there is a solution for it.