A Bug? .. $dataTable->Rows->Add($newRow) .. no working.

Discussion about the managed MySql extension [?] for Phalanger.

A Bug? .. $dataTable->Rows->Add($newRow) .. no working.

Postby kielsoft » May 31st, 2011, 8:56 am

Seem there is a problem somewhere, don't know if its a bug, when converting the c# code on this page to phalanger PHP works differently from the normal expected output.

http://msdn.microsoft.com/en-us/library/system.data.datatable.newrow.aspx


Pls what is what do you think its wrong with
$datatable->rows->add($row);

$row is an object (I.e DataRow class ) and when I useadd() method,  it adds it like a string and will show 'System.Data.DataRow' in theDataGridView ....

kielsoft
 
Posts: 25
Joined: March 1st, 2012, 3:39 pm

RE: A Bug? .. $dataTable->Rows->Add($newRow) .. no working.

Postby kielsoft » May 31st, 2011, 8:44 pm

Method Invocation
Dynamic methods are generated at runtime also for methods invoked on CLR types. The PHP
language does not support method overloading and there is currently no way how to provide a hint
for the compiler as to in which overload the user is interested. Thus the principal task of a stub is to
choose the most appropriate overload of the target method based on the number and types of the
supplied actual arguments.
Each stub contains a switch which essentially filters out overloads with the number of formal
parameters that is smaller or greater than the number of actual arguments supplied to the call.
Afterwards, the overloads with the correct number of parameters are tested one-by-one by trying to
convert arguments to their parameter types. The first overload, for which all arguments are
convertible to its parameter types, receives the invocation. The conversions must constitute a
sensible trade-off between dynamism and selectivity. PHP can convert any type to just about any
other type but if the conversion routines behaved like this, inappropriate overloads would have been
called. For instance, every object in PHP is implicitly convertible to a number, which yields either 0 or
1 depending on whether there are any fields in the object. The conversion routines involved in
overload resolution must suppress these heavy-weight conversions.
Phalanger fully supports calling methods with ref and out parameters, because PHP contains the
notion of by-reference argument passing. If an argument is about to be passed by reference, it is
pushed to the stack wrapped by a PhpReference. The value is unwrapped, converted to the
corresponding parameter type, stored to a local variable, and the address of the local is passed to the
target method. When the method returns, the (possibly updated) local is converted back to
Phalanger type and stored back to the PhpReference.
Methods with a params parameter, i.e. an array parameter decorated by the
ParamArrayAttribute, have slightly more complicated stubs. Consider the following set of
overloads.

void Foo();void Foo(int x1);void Foo(int x1, int x2);void Foo(int x1, int x2, int x3);void Foo(params object[] args);


The last params overload can become the most appropriate overload for every argument count
except for zero. The generated stub for this set of overloads has to consider it in every switch
branch because if the conversions to int fail, the last overload is a fallback. Moreover, there must
be a default case containing a loop, in which all actual arguments are converted to the params array.
Finally, the params overload can also be called by explicitly passing an array, so the switch branch
for exactly one argument on the stack contains the following.

POP arg1 from stack
IF arg1 is convertible to int, call the Foo(int) overload
ELSE IF arg1 is convertible to object, create new object[] { arg1 } and call the Foo(object[]) overload
ELSE IF arg1 is convertible to object[], call the Foo(object[]) overload
ELSE error

kielsoft
 
Posts: 25
Joined: March 1st, 2012, 3:39 pm

RE: A Bug? .. $dataTable->Rows->Add($newRow) .. no working.

Postby kielsoft » May 31st, 2011, 8:51 pm

Could this be my problem? I found that in "Phalanger: Integrating PHP with CLR" by  Ladislav Prošek, Tom áš M atoušek, Page 7 & 8.


Can someone please show me how to implement ..... 

POP arg1 from stack
IF arg1 is convertible to int, call the Foo(int) overload
ELSE IF arg1 is convertible to object, create new object[] { arg1 } and call the Foo(object[]) overload
ELSE IF arg1 is convertible to object[], call the Foo(object[]) overload
ELSE error


.....in PHP. 

I have tried this $datatable->rows->add((object) $row);  and it is not working.

Thanks.

kielsoft
 
Posts: 25
Joined: March 1st, 2012, 3:39 pm

RE: A Bug? .. $dataTable->Rows->Add($newRow) .. no working.

Postby kielsoft » June 1st, 2011, 4:27 pm

Please say something helpful.

kielsoft
 
Posts: 25
Joined: March 1st, 2012, 3:39 pm

RE: A Bug? .. $dataTable->Rows->Add($newRow) .. no working.

Postby kielsoft » June 15th, 2011, 4:39 pm

Can someone help with this and let me know is it's a bug or there is another way to do this? or if my code is needed I can mail it to you.

kielsoft
 
Posts: 25
Joined: March 1st, 2012, 3:39 pm

Re: A Bug? .. $dataTable->Rows->Add($newRow) .. no working.

Postby Leo123 » January 4th, 2014, 7:36 am

$row is an object (I.e DataRow class ) and when I useadd() method, it adds it like a string and will show 'System.Data.DataRow' in theDataGridView ....
Leo123
 
Posts: 1
Joined: January 4th, 2014, 7:22 am


Return to MySql Extension project

Who is online

Users browsing this forum: No registered users and 2 guests

cron

User Control Panel

Login

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests (based on users active over the past 5 minutes)
Most users ever online was 256 on March 28th, 2024, 9:42 am

Users browsing this forum: No registered users and 2 guests