This topic is locked

dal changed in 5.2?

3/3/2010 8:31:04 AM
PHPRunner General questions
W
wpl author

Hi list,
in PHPRunner 5.1 I used to code like so:
global $dal;
$rs = $dal->public_tablename->Query($SQLstatement);
......
With 5.2 I get:
Fatal error: Call to a member function Query() on a non-object in ....\include\tablename_events.php on line 134
What happened to dal?
TIA

Sergey Kornilov admin 3/3/2010

In version 5.2 you need to use the following:

$rs = $dal->Table["tablename"]->Query($SQLstatement);


When you open v5.1 project your code will be adjusted automatically.

More info is available in PHPRunner 5.2 manual.

W
wpl author 3/3/2010



In version 5.2 you need to use the following:

$rs = $dal->Table["tablename"]->Query($SQLstatement);


When you open v5.1 project your code will be adjusted automatically.

More info is available in PHPRunner 5.2 manual.


Sergey,
my code in 5.1 was



function BeforeDelete($where,&$deleted_values)

{
global $dal, $conn;

.

.

.

$rs = $dal->public_tablename->Query($SQLstatement);
.

.



After opening with 5.2 it looks like:



function BeforeDelete($where,&$deleted_values,&$message)

{
global $dal;

$dal->Table("public_tablename1");

$dal->Table("public_tablename2");

$dal->Table("public_tablename3");

global $dal, $conn;

.

.

.

$rs = $dal->public_tablename->Query($SQLstatement);



Any idea?

Sergey Kornilov admin 3/3/2010

I guess I owe a full explanation.
In version 5.1 you can use both ways. This works nice however increases the amount of code and slows down execution. In PHPRunner 5.2 we have changed that so DAL objects are created on demand.

$dal->Table("tablename")->Query($SQLstatement);

// works always and is recommended way to write code.


$dal->tablename will work only if table object was initialized previously.

So, the following will work as well:

$dal->Table("public_tablename"); // initialization

$rs = $dal->public_tablename->Query($SQLstatement); // use
W
wpl author 3/3/2010



I guess I owe a full explanation.
In version 5.1 you can use both ways. This works nice however increases the amount of code and slows down execution. In PHPRunner 5.2 we have changed that so DAL objects are created on demand.

$dal->Table["tablename"]->Query($SQLstatement);

// works always and is recommended way to write code.


$dal->tablename will work only if table object was initialized previously.

So, the following will work as well:

$dal->Table["public_tablename"]; // initialization

$rs = $dal->public_tablename->Query($SQLstatement); // use



Sergey,
thanks for your patience. But, sorry, using



$dal->Table["public_tablename"];


will throw the following error:



Undefined property: tDAL::$Table
Sergey Kornilov admin 3/3/2010

My fault, Table() is a function. Updated my post.

E
electromotive 3/3/2010

Thanks for clearing this up, I've been messing with it the past day tryna get it working too <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=48223&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />
And although the new code $dal->Table("table") generates a syntax error:

> syntax error, unexpected T_OBJECT_OPERATOR in line 3
The code runs correctly.

Sergey Kornilov admin 3/4/2010

electro rick,
could you clarify where and when this error message appears? You can post the whole piece of code here.

W
wpl author 3/4/2010



My fault, Table() is a function. Updated my post.


Sergey,
thanks.



$dal->Table("tablename")->Query($SQLstatement);


will work. Just got a bit confused about a table's name and varname.

W
wpl author 3/4/2010



In version 5.2 you need to use the following:

$rs = $dal->Table["tablename"]->Query($SQLstatement);


When you open v5.1 project your code will be adjusted automatically.

More info is available in PHPRunner 5.2 manual.


Sergey,
I believe that what gets inserted by PHPRunner 5.2 when opening a 5.1 project is not correct.



$dal->Table("public_tablename"); // initialization

$rs = $dal->public_tablename->Query($SQLstatement); // use


Whereas it should be:



$dal->Table("tablename"); // initialization

$rs = $dal->public_tablename->Query($SQLstatement); // use


It seems to me that public_tablename will be initialized by $dal->Table().