Re: DataObjects: Rows inserted in triplicate

From: Date: Tue, 22 Feb 2005 23:23:20 +0000
Subject: Re: DataObjects: Rows inserted in triplicate
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17630@lists.php.net to get a copy of this message
On Tue, 22 Feb 2005 15:16:28 -0800, Sasha Sklar <Sasha.Sklar@craveonline.com> wrote: > > Justin, thanks for taking so much time with this. > > I tried a variety of things, from sending an email to echoing junk to > the screen. From all I can see, the function is only being called once. > > When you refer to the database.ini file, are you talking about this: > [DB_DataObject] > > database = BALETED > schema_location = /home/sasha/host/sasha/DataObjects > class_location = /home/sasha/host/sasha/DataObjects > require_prefix = DataObjects/ > class_prefix = DO_ > > Or are you referring to the schema? I didn't have a schema, because I > thought that manually generated classes didn't need it. I meant the schema file. You always need the schema file unless you're overriding the table() method of the class to return the schema and the keys() method to return the right array. If you don't have these you 1) have key/sequence problems, as you saw, and 2) all fields are assumed to be text. Putting in the types (the schema file) makes things work a lot better and more correctly. Plus this allow FormBuilder to work (check it out if you haven't ;-) ). > One was > generated along with the DO clases. Here's the entry for the test table: > > [test] > test_id = 129 > test_value = 2 > > [test__keys] > test_id = N > > Just so you know, I've actually used this library many times with ease. > I've always used manually generated files up till now and never had a > problem. It's just that I've started a new job and after extolling the > virtues of PEAR:DataObject to my new co-workers, I'm starting to sweat a > bit. I'm tempted to upload the files to my own private server, create a > copy of the table there, and see what happens. Is there anything else > you can think of that would be tripping things up? Any other information > I can give you? So what's the DB backend? Mysql? ODBC? Oracle? > > -----Original Message----- > From: Justin Patrin [mailto:papercrane@gmail.com] > Sent: Tuesday, February 22, 2005 2:14 PM > To: Sasha Sklar > Cc: pear-general@lists.php.net > Subject: Re: [PEAR] DataObjects: Rows inserted in triplicate > > On Tue, 22 Feb 2005 14:07:22 -0800, Sasha Sklar > <Sasha.Sklar@craveonline.com> wrote: > > OK, couple of things. I noticed an error in my manually created class. > I > > had copy/pasted the code for the staticGet function, and forgotten to > > change the name of the table. > > > > I ran the generator, and it worked fine. I tested the generated class, > > and it is doing the same thing, but it doesn't seem to be creating the > > seq table anymore. > > The seq table thing was a problem in your database.ini file, then. You > probably didn't set up the key value correctly when you created those > manually. Actually, your problem could well have been that you didn't > even have an ini file. ;-) Actually, this ini file is pretty hard to > manually generate, I'm surprised you got your code working at all. > > As for the multiple insert, try adding a mail() call to your code just > before the insert() call. Perhaps your script is being called multiple > times? Or it's in a loop or something? There really is no way that a > single insert can create multiple records unless your backend DB is > really screwed up. > > > > > -----Original Message----- > > From: Justin Patrin [mailto:papercrane@gmail.com] > > Sent: Tuesday, February 22, 2005 1:41 PM > > To: Sasha Sklar > > Cc: pear-general@lists.php.net > > Subject: Re: [PEAR] DataObjects: Rows inserted in triplicate > > > > On Tue, 22 Feb 2005 13:23:15 -0800, Sasha Sklar > > <Sasha.Sklar@craveonline.com> wrote: > > > Justin, > > > > > > Thanks for the info on running the generator. I'm going to give it a > > > try, although there is some resistance in my team to using the > > generated > > > classes. Not logical, I know, but that's work politics. > > > > The auto-gen classes are just as good as normal manual classes except > > they're automatic. :-) It only touches the auto-gen code, so as long > > as you put custom functions and such outside of the markers you're > > fine. > > > > > > > > We're using PHP 4.3.9. That is the entirety of the script, aside > from > > > some html for formatting and the configuration code at the top. I'll > > > list that and my config file: > > > > > <snip> > > > I've noticed a weird table in the database which I did not create. > It > > is > > > called test_seq. It contains a single row with a single field called > > id. > > > The id value is equal to the last id in test. If I remove the table > > and > > > run my script, it is regenerated. > > > > > > Any ideas? > > > > Ah....this is DB creating a sequence table because DB_DataObject > > thinks that this is a DB generated sequence. What DB backend are you > > using? Mysql? Is your ID set up as a auto incremented value? Do you > > have it set up as your primary key? > > > > > > > > -----Original Message----- > > > From: Justin Patrin [mailto:papercrane@gmail.com] > > > Sent: Tuesday, February 22, 2005 1:08 PM > > > To: Sasha Sklar > > > Cc: pear-general@lists.php.net > > > Subject: Re: [PEAR] DataObjects: Rows inserted in triplicate > > > > > > On Tue, 22 Feb 2005 12:33:52 -0800, Sasha Sklar > > > <Sasha.Sklar@craveonline.com> wrote: > > > > This is the issue: every insert I perform is generating 3 rows > > instead > > > > of 1. > > > > > > > > I'm using DataObjects with manually created classes, I can't use > the > > > > generator do to permission issues. > > > > > > > > > > What permissions issues? If you can't run it via CLI for some reason > > > you can always run the generator from the web. Just set the > > > permissions on the class dir (and files) to 777. Here's a simple > > > script I use to update some of my DOs from the web: > > > > > > <?php > > > $_SERVER['argv'][1] = '/path/to/DataObject.ini'; > > > include('/path/to/PEAR/DB/DataObject/createTables.php'); > > > system('chmod 777 /path/to/DataObjects/*'); > > > ?> > > > > > > If you need more help, what's the output of the script you gave? Is > > > that the entirety of the script or is there more? What version of > PHP > > > are you using? > > > > > > > -- > Justin Patrin > > -- Justin Patrin

« previous php.pear.general (#17630) next »