This topic is locked

Bug? Insert Record Event on table VIEW .$strTableName.

5/6/2009 8:27:53 AM
PHPRunner General questions
S
sloftus author

I'm using PHPRunner 5.0 build 766
Think I may have found a small bug. If it is not please delete this post (I won't be offended <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=11763&image=1&table=forumtopics' class='bbc_emoticon' alt=':)' />)
Example: I have a table view called TABLE_VIEWwhich is based on an actual table called TABLE1. I want to add an event in TABLE_VIEWEdit page before record updated to Save old data record in another table. The code is.....
//** Save old data record in another table ****

global $conn,$strTableName;
$strSQLSave = "INSERT INTO AnotherTable (Field1, Field2) SELECT Field1, Field2 FROM ".$strTableName." where ".$where;

db_exec($strSQLSave,$conn);
However the code generates an SQL error because ".$strTableName." takes the name I gave the view (TABLE_VIEW) rather than the REAL table that the view was based upon (TABLE1).
In order to get this to work I modified the code as follows.....
$strSQLSave = "INSERT INTO AnotherTable (Field1, Field2) SELECT Field1, Field2 FROM "TABLE1" where ".$where;

db_exec($strSQLSave,$conn);
This bug may have been fixed in later versions.

J
Jane 5/6/2009

Hi,
it's not bug.

$strTableName returns name of current table or view.

$strOriginalTableName returns actual table name for view created in PHPRunner.

S
sloftus author 5/6/2009

Hi,

it's not bug.

$strTableName returns name of current table or view.

$strOriginalTableName returns actual table name for view created in PHPRunner.


Hi Jane, The code example I used was generated automatically by the 'Add Action' option on the events page. In which case PHPRunner is generating the wrong code. I think it should generate.....
$strSQLSave = "INSERT INTO AnotherTable (Field1, Field2) SELECT Field1, Field2 FROM ".$strOriginalTableName." where ".$where;

db_exec($strSQLSave,$conn);
however I tried this and got an undefined variable error.
Anyway..for now I'll just insert the original table name manually.

Sergey Kornilov admin 5/6/2009

I recommend to post your application to Demo Account (use 'Demo Account' button on the last screen in program). Then open a ticket at http://support.xlinesoft.com sending your Demo Account URL for investigation.

J
Jane 5/7/2009

Hi,
please make sure you have defined this variable:

global $strOriginalTableName;

$strSQLSave = "INSERT INTO AnotherTable (Field1, Field2) SELECT Field1, Field2 FROM ".$strOriginalTableName." where ".$where;

...