Sign in to follow this  
Followers 0
Edifice

_SQLite_Exec

8 posts in this topic

A couple of days ago I found an example somewhere, great one actually.

However, it has these two lines in it:

If $retarr[0] <> "" Then
        _SQLite_Exec($dbn,"UPDATE datas SET id='"&$str1&"', modtager='"&$str2&"',timeanddate='"&$str3&"' ,navn='"&$str4&"' ,telefonnummer='"&$str5&"',email='"&$str6&"' ,indleveret='"&$str7&"',garanti='"&$str8&"' ,fakturanummer='"&$str9&"' ,color='"&$str10&"' ,brand='"&$str11&"' ,diversebeskrivelse='"&$str12&"' ,accesory='"&$str13&"' ,diversetlbhr='"&$str14&"' ,fejlbeskrivelse='"&$str15&"' ,antaltimer='"&$str16&"' ,reservedel1='"&$str17&"' ,pris1='"&$str18&"' ,reservedel2='"&$str19&"' ,pris2='"&$str20&"' ,reservedel3='"&$str21&"' ,pris3='"&$str22&"' ,reservedel4='"&$str23&"' ,pris4='"&$str24&"' ,reservedel5='"&$str25&"' ,pris5='"&$str26&"' ,ialtprice='"&$str27&"'   WHERE id='"&$id&"'")
    Else
        _SQLite_Exec($dbn,"INSERT INTO datas (id,modtager,timeanddate,navn,telefonnummer,email,indleveret,garanti,fakturanummer,color,brand,di

versebeskrivelse,accesory,diversetlbhr,fejlbeskrivelse,antaltimer,reservedel1,pris1,reservedel2,pris

2,reservedel3,pris3,reservedel4,pris4,reservedel5,pris5,ialtprice) VALUES ('"&$str1&"','"&$str2&"','"&$str3&"','"&$str4&"','"&$str5&"','"&$str6&"','"&$str7&"','"&$str8&"','"&$str9&"','"&$str10&"','"&$str11&"','"&$str12&"','"&$str13&"','"&$str14&"','"&$str15&"','"&$str16&"','"&$str17&"','"&$str18&"','"&$str19&"');")
    EndIf

As far as I see it, it's just two different ways of doing the same thing but am I missing something? - and in that case what?

Share this post


Link to post
Share on other sites



One does UPDATE, the other does INSERT. Look up those functions at the SQLite web site, or any other SQL reference to see the difference.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Yes I got that part. It's the way it's done I'm thinking of?

Share this post


Link to post
Share on other sites

Yes I got that part. It's the way it's done I'm thinking of?

What...? :)

A little early in the day to be that wobbly, isn't it?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Update = change existing entry

Insert = make new entry

_SQLite_Exec simply takes a SQL query and executes it, after a SQLite database has been opened.

Share this post


Link to post
Share on other sites

Yes, I also follow that. But:

One of the type has all the strings seperatly and one has them right after the location in the database. As I see it it makes no difference, and I was just wonderng whether it was important or not?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Im under the understanding that if you specify where you want to place it, it will replace that- i.e

INSERT INTO table (col,col,col) VALUES (value, value, value)

Otherwise with update, it will set what you specify col=value etc.

But as they are 2 DIFFERENT queries, I recommend you read up on them, all your questions should be answered just by searching for it :)

Cheers,

Brett

Edited by BrettF

Share this post


Link to post
Share on other sites

Thanks! I get why there is a difference now - you just cleared it up in a single sentence :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0