Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Dynamic Query and default run-time values

Community Beginner ,
Jan 17, 2008 Jan 17, 2008
I am trying to build a dynamic query within dreamweaver and retain access from the bindings panel.
here is a simple pseudo-query I want to expand on.

"SELECT object FROM objects_table WHERE widget_number = widgets"

widgets is set up as a variable with a run-time value that relates to $_GET['widgets']

this works fine but now i want to expand on this so the query returns all results if $_GET['widgets'] is undefined. I was hoping I could set the default value for widgets to equal widget_number so I would get....

"SELECT object FROM objects_table WHERE widget_number = widget_number" but the runtime query is actually

"SELECT object FROM objects_table WHERE widget_number = 'widget_number' " which obviously doesn't work.

I can alter the query manually from the code view but then I lose access to the bindings panel as dreamweaver doesn't parse the query properly.

Any pointers?

Thanks in advance

- Andrew
TOPICS
Server side applications
375
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 17, 2008 Jan 17, 2008
Andy Millne wrote:

> I am trying to build a dynamic query within dreamweaver and retain access from
> the bindings panel.
> here is a simple pseudo-query I want to expand on.
>
> "SELECT object FROM objects_table WHERE widget_number = widgets"
>
> widgets is set up as a variable with a run-time value that relates to
> $_GET['widgets']
>
> this works fine but now i want to expand on this so the query returns all
> results if $_GET['widgets'] is undefined. I was hoping I could set the default
> value for widgets to equal widget_number so I would get....
>
> "SELECT object FROM objects_table WHERE widget_number = widget_number" but the
> runtime query is actually
>
> "SELECT object FROM objects_table WHERE widget_number = 'widget_number' "
> which obviously doesn't work.
>
> Any pointers?
>
> Thanks in advance
>
> - Andrew
>
$query="SELECT object FROM objects_table";
if (!isset($_GET['widgets']) ) {
$query. = " WHERE widget_number = widget_number";
}
else{
query.=" WHERE widget_number = widgets;

}


Someyhing like that.
Mick

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 17, 2008 Jan 17, 2008
That will work fine server-side yeah but dreamweaver cannot parse the code at design time so by altering the code in this way you lose access to the bindings panel,and all the server behaviours that depend on the recordset have exclamation marks alongside.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 17, 2008 Jan 17, 2008
basically what I am after is some way of setting the default value equal to the current value in the database and still have the protection from SQL injection.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 18, 2008 Jan 18, 2008
Andy Millne wrote:
> That will work fine server-side yeah but dreamweaver cannot parse the code at
> design time so by altering the code in this way you lose access to the bindings
> panel and all the server behaviours that depend on the recordset have
> exclamation marks alongside.

This is simply a question of organizing your workflow. As you have
discovered, Dreamweaver no longer recognizes a recordset if you make
changes to the basic structure of the code. The answer is to use
Dreamweaver to construct your page using an unaltered recordset. Once
the design stage is complete, make the changes required by inserting
your conditional statement. Yes, the fieldnames disappear from the
Bindings panel, and you get exclamation marks in the Server Behaviors
panel, but that's not important. If you need to restore them for any
reason, just wrap the changes in /* */ comments. Remove the comments
when you have finished.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 18, 2008 Jan 18, 2008
LATEST
David is right. Sooner or later you will have to modify code to get
the results you want. DW is great becuase it gives you a structure and
saves many an hour typing and debugging code. I have done both and I
choose initial DW design and fine tuning with manual changes.

Unless your site is very basic sooner or later you have to get your
hands down and dirty.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines