close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

update multiple

Thread began 4/26/2009 6:10 am by office377308 | Last modified 4/30/2009 8:51 am by Ray Borduin | 6661 views | 10 replies |

office377308

update multiple

I have a table which does not have one field as a uniqe key in mysql but two:
The PRIMARY KEYs are together
categories_id
language_id
because the categories_id is a foreign key, belonging to the parent table. The language_id is numeric as well.
Both are not auto_incremental, but are written into the table.
In this way, web assists "Multiple Record Inserts" is working properly.
Not so with Update Multiple Records:
If I try to bind categories_id as the categories_id (which is only half of the truth), updates simply don't work. There is also no error message.
How shall I proceed?

Sign in to reply to this post

Ray BorduinWebAssist

Maybe create a view of the joined columns so that they can be treated as a single column.

Sign in to reply to this post
Did this help? Tips are appreciated...

office377308

Originally Said By: Ray Borduin
  Maybe create a view of the joined columns so that they can be treated as a single column.  



sorry, I am at loss. This is php/mysql server model. How do I create a "view of the joined columns"? Did I miss something?

Sign in to reply to this post

Ray BorduinWebAssist

What version of mySQL? mySQL 5 supports the use of views. There is a function in php called CONCATINATE that will join column values into a single column.

Sign in to reply to this post
Did this help? Tips are appreciated...

office377308

Oh, I see. I thought there is a hidden function in Dreamweaver or DA

Sign in to reply to this post

office377308

still no updates

i did this:
// WA DataAssist Multiple Updates
....
$WA_indexField = "CONCAT(categories_id,language_id)";
....

is there something else which needs changing?
any advice welcome!

Sign in to reply to this post

Ray BorduinWebAssist

You would have to debug it. It may have SQL injection code preventing complex values like that to be passed in directly. This is not part of our testing, so it isn't really directly supported in this way. You may need to do some hand edits to get something like that working properly. Write the resulting SQL statement to the page and see if it writes what you would expect. It may work I just haven't tried that technique which is why I recommended creating a view so the concatinated fields appeared as a single column.

Sign in to reply to this post
Did this help? Tips are appreciated...

office377308

Even DA's "update single behaviour" does not work. DW CS3's basic update record does.

Originally Said By: Ray Borduin
  You would have to debug it.  



I think, I should not. I'd rather suggest, DA should update its extension to provide this feature, BECAUSE:

Even with update single record, it does not work.
BUT Dreamweaver's basic "update record" server behaviour recognizes the two primary fields immediately and does a correct job.:

If my update form looks something like

<form method="POST" name="update_descr">
<input name="language_id" type="hidden" value="<?php echo $_GET['sp']; ?>" />
<input name="category_id" type="hidden" value="<?php echo $_GET['catid']; ?>" />
<input name="language_description" type="text" value="<?php echo $_GET['inhalt']; ?>" />
<input type="submit" name="update" id="update" value="update" />
</form>

Dreamweavers built in update behaviour does this:

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "update_descr")) {
$updateSQL = sprintf("UPDATE categories_description SET categories_name=%s WHERE categories_id=%s AND language_id=%s",
GetSQLValueString($_POST['language_description'], "text"),
GetSQLValueString($_POST['category_id'], "int"),
GetSQLValueString($_POST['language_id'], "int"));

mysql_select_db($database_string, $string);
$Result1 = mysql_query($updateSQL, $string) or die(mysql_error());
}

// ....

shortly: Dreamweaver does recognize both PRIMARY key fields and correctly updates the record.
But Dreamweaver only understands "update single record behaviour".

My question is, why does DATA ASSIST's not even offer this functionality in its "update single record" not to mention the multiple one?
(I am only offered to select a single id as primary key here.)

Because that was the reason I bought this extension. To go beyond Dreamweavers basic functions.

Again this is the table structure:

CREATE TABLE IF NOT EXISTS `categories_description` (
`categories_id` int(11) NOT NULL default '0',
`language_id` int(11) NOT NULL default '1',
`categories_name` varchar(64) collate utf8_unicode_ci NOT NULL,
PRIMARY KEY (`categories_id`,`language_id`),
KEY `idx_categories_name` (`categories_name`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

Please don't ask me to hack DA server behaviour but show me the right way!

Sign in to reply to this post

Ray BorduinWebAssist

I believe the correct way is to define the view in your mySQL database as I have contended. Thank you for pointing out this missing feature. You are the first to report it, so it isn't very common for our users to deal with multiple primary keys. I will add it as a feature suggestion for the next release, but no amount of hand waving will make it work the way you want. You either need to create a view in the mySQL database or possibly debug and hack your way through adding this feature to DataAssist because the feature does not exist currently.

Sign in to reply to this post
Did this help? Tips are appreciated...

office377308

The coin dropped

Thank you for insisting on creating a "VIEW". You meant it litterally. This I did not understand.
Yes, I think this is the best solution

CREATE VIEW categories_description_v AS SELECT categories_id, language_id, CONCAT(categories_id, language_id) AS mainkey, categories_name FROM categories_description;

I guess, thats what you had in mind.
And it works without hacking DA's extension. Still, as a suggestion: do include it in a further update because some servers don't allow creating views.

Thanks again for your assistance!

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...