[SOLVED] Â Dynamically add where clause to the search suggest: reprise |
6/19/2012 4:46:17 PM |
PHPRunner General questions | |
W
wpl author
Hi All, |
|
C
|
cgphp 6/19/2012 |
Did you try the FunkDaddy solution (last answer in the post)? |
W
|
wpl author 6/20/2012 |
Did you try the FunkDaddy solution (last answer in the post)?
|
J
|
Jane 6/20/2012 |
I recommend you to have a look at this article: |
W
|
wpl author 6/20/2012 |
I recommend you to have a look at this article: http://xlinesoft.com/phprunner/docs/addwhere.htm
|
J
|
Jane 6/21/2012 |
Could you publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this issue? |
W
|
wpl author 6/22/2012 |
Could you publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this issue?
|
W
|
wpl author 6/26/2012 |
Jane, the project is too big and too complex to publish. But I will try to desrcibe better what's happening. Let's say I have two tables tableMaster and tableDetail, each of which has (among others) three fields id1, id2, id3 which in each case are joined to the tables tableId1, tableId2, tableId3 which also contain the fields id1, id2, id3. In tableDetail I would like to limit the results of searchsuggest.php in Quicksearch to the records the list page is limited to in the BeforeQueryList event using whereAdd. So I used the following code in the AfterTableInitialized event of tableDetail: $query->addWhere("tableDetail.id1=".$_SESSION["id1"]); I had to qualify the fieldname with the tablename because id1 is also contained in tableId1, tableId2, and tableId3) which are joined to tableDetail. This will work fine, but, as there will be more fields (id2, id3) and more conditions to be considered, and there are several tables following this pattern, I wanted to code it in a more generalized way like so: global $strTableName; $query->addWhere($strTableName . "." . "id1=" . $_SESSION["myuserid"]); This will work when tableDetail is called directly from menu or via url. However, if tableMaster is called (and from here, AfterTableInitialized of tableDetail will be called also), there will be an error because $strTableName in the AfterTableInitialized event of tableDetail will contain the name 'tableMaster' but addWhere will append the condition to the SQL string of tableDetail so that the query reads: ...from tableDetail1 where tableMaster.id1=.... and there will be an error "missing entry 'tableMaster' in FROM clause..". Any hint to cope with this? I would really like to avoid hard coding the name of the table in each AfterTableInitialized event. Thanks
|
![]() |
Sergey Kornilov admin 6/27/2012 |
I'm not sure how we can help without having access to your files and database. |
W
|
wpl author 6/27/2012 |
I'm not sure how we can help without having access to your files and database.
|
![]() |
Sergey Kornilov admin 6/27/2012 |
If I understand your question right you can find what's the current URL is (master or details table) and apply this logic in your code. |
W
|
wpl author 6/29/2012 |
If I understand your question right you can find what's the current URL is (master or details table) and apply this logic in your code.
|