9 years ago
4
Topic

Hi, 

I created a form which works well to set up new item but I didn't find how configure the form to update already database saved item.

The table is : id (autoincrement, primary), uid (user id, unique), data A, data B, data C.

The form pick up data in SQL from uid filter (with the active user id) and put the values as default on form. But, when I wanna save new data on the same UID, the form try to make a INSERT SQL command instead of UPDATE SQL command. 

Someone can tell me how to set up the form to make an update command when UID already exists ?

Thank you !

Get a VIP membership
9 years ago
1
Level 1

Hello nmerigot,

welcome on SEBLOD forum.

With what you say, I think you are adding SEBLOD on an existing website with some existing contents ?

There are more notions to have in mind on how work SEBLOD.

It's not so simple to add SEBLOD on an existing website, because SEBLOD have it's own management of database.

In your table, the INSERT or UPDATE will be done on the primary key, so not on the user_id.

An other thing, is how have you setup each field of your form, and specially their storage?


Regards.

Lionel

9 years ago
0
Level 2

> With what you say, I think you are adding SEBLOD on an existing website with some existing contents ? 

No, it's a new website project.

> An other thing, is how have you setup each field of your form, and specially their storage?

Each field are Standart | Free | table_name | column name. Default value is set with a SQL Query on UID = actual User ID (little hack I found on this forum and adapt to live value sql query to replace [me] to actual user ID).

It's working fine with the id (primary key) passed as hidden value ! Thanks !

But now I've another issue : I don't know why SEBLOD put <br />::catid_back:: before the data (and something similar after) in the table. catid_back is the name of a field in the form but another field with exactly the same options doesn't put the field name before data and just put the data (as I want). An idea ? Maybe a new topic ? :)

9 years ago
1
Level 1

hello nmerigot,

I think you have not beginning on the good base.

What we advise is to not manage database by yourself, but let SEBLOD do that for you.

In 99% of case, you just have to use the STANDARD storage for your field. You can have a look to this tutorial on the storage.

The FREE storage must be used in very special case; when it's not possible to do with STANDARD storage.


The tag you seen <br />::catid_back::  , it's due to the storage CUSTOM, so you probably have a field with a bad storage.


What I advise in your case, it's to remove your custom table, and delete your content type with all fields, then start a new content type on the good way.

Also, don't hesitate to have a look on all manuals


Regards.

Lionel

9 years ago
0
Level 2

It works ! :)

THANKS !

Get a Book for SEBLOD