[Openledger-developer] The correct way to db?
Brought to you by:
klavs
From: Klavs K. <kl...@vs...> - 2005-03-04 16:23:02
|
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi guys, I can see SL uses AutoCommit (not good when it's doing several transactions - as in post_transaction) :( I suggest we agree on a way to do DB transactions :) I'd suggest using commit/rollback - and (it was news to me) using ? in the prepare statements, to replace values, which is then given in the execute($var1,$var2,...) call when executing. Also - I'm used mysql being able to tell me the ID of the last_insert_id (ie. resulting ID of last INSERT), which is appearently a unique feature of MySQL :) I see SL (ie. Dieter) is generating it's own unique ID and then replacing on that :( I'd prefer using sequences like this: ~ # first generate a unique id for this table ~ id = dbh.select_one("SELECT nextval('"id"').first ~ # now insert row ~ dbh.do("INSERT INTO test (id, name, phone) VALUES (?,?,?)", id, "foo", "42") The thing is, that currently the SL db has 3 sequences, id, invoiceid and orderitemsid - and I'm not a 100% sure that I can use id for the gl table? If I can use it - then isn't that the correct way to do it? - -- Regards, Klavs Klavsen, GSEC - kl...@vs... - http://www.vsen.dk PGP: 7E063C62/2873 188C 968E 600D D8F8 B8DA 3D3A 0B79 7E06 3C62 "Those who do not understand Unix are condemned to reinvent it, poorly." ~ --Henry Spencer -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQFCKItuPToLeX4GPGIRAicZAJ9jtsi7qfoJiMreXQNkrex4oiQ+tQCfWLsA DL7rA4tLphugcuY9lTH/kGs= =64WY -----END PGP SIGNATURE----- |