DbInstallSandbox

3 views
Skip to first unread message

Matt Edmonds

unread,
Apr 29, 2011, 4:21:48 AM4/29/11
to cis605
Mihaela,

When I run DbInstallSandbox, There are problems with the data entries
for Individual and Organization. Individual shows that all Id numbers
are set at 0, but appears to add the entries correctly when checked in
the command line. The data entries for the organization table are not
working at all from the Sandbox. When checked in the cmd, Organization
shows an empty set.

I am not sure where this problem is originating.

Matt Edmonds

unread,
Apr 29, 2011, 4:23:04 AM4/29/11
to cis605
Here is a screenshot of what it does when I run sandbox. Despite the output for Organization, it always ends up as an empty set.
Sandbox.png

Sabin, Mihaela

unread,
Apr 29, 2011, 7:20:50 AM4/29/11
to cis...@googlegroups.com
I'll look at the code in the afternoon, after I'm done grading for the database class. Thank you for making the post.

Mihaela

Scott

unread,
Apr 29, 2011, 8:41:51 PM4/29/11
to cis605
Don't know if this helps, but you have some values in the insert
statements that are primary/foreign keys that correspond to
autoincremented primary keys (i.e in Organization the donorid is a
foreign key). I believe for those statements you should have a null
instead of a 1, 2, etc. It looks like you did that for some of the
others by not including the values. As a side, I don't know if when
you run it your old values are being overwritten (i.e. for Event
there's an eventid thats primary and autoincremented). Like if you do
an insert in mysql, does it just override what was in a particular
spot before? If so, there should be nulls for those too, and then when
it runs it'll just add more rows to the database instead of
overwriting what's there. The organization statements may stop because
a primary key (donorid) is associated with primary donorid in donor,
so the constraint doesn't allow the override. Bottom line I think you
can just do nulls for all autoincremented primary keys. Hopefully some
of that made sense.
> > I am not sure where this problem is originating.- Hide quoted text -
>
> - Show quoted text -

Matt Edmonds

unread,
Apr 29, 2011, 11:20:34 PM4/29/11
to cis...@googlegroups.com
Scott, you are correct in the case of auto increment primary keys, However with foreign keys, they must be pointed towards specific entries in other tables. The numbers 1,2 etc are what link those tables to the other tables with auto increment keys.

Scott

unread,
Apr 30, 2011, 12:13:10 PM4/30/11
to cis605
Ya your right I see that now. That being said I really don't know.
Maybe something in the module in the add function? Inserts look right.
Good luck man.

Scott

unread,
May 1, 2011, 5:10:33 PM5/1/11
to cis605
I've been working on our sandbox all day here and I was getting some
of the same problems Matt was having. When I commented out the inserts
that weren't working tables that returned id 0 started working right.
I'm still not sure exactly what the problem is. Super frustrating by
the way. Didn't know if anyone (i.e. Matt) had any success in fixing
them. Now if I comment out UserType, UserName, UserProsCouns,
CounselingStatus, and CounselingType, sandbox works fine, and when I
run it I get the correct ids back (i.e 1,2,3 and then 4,5,6) and I can
confirm in command line. If I run the sql scripts first (to clear the
database), and then run dbInstallsandbox, the CounselingStatus and
CounselingType statements also work the first time around. What is odd
though is that when I check in command line, i don't get the empty set
message, but the actual values that should be there are not, as if the
insert statement was inserting nulls somehow. Like for
CounselingStatus the values should be 'completed', 'completed', but
command line (when I do select *) returns the table with '(blank
space) ', '(blank space) '. If I run sandbox again, the second time
the inserts don't work for CounselingStatus or CounselingType. I have
gone through the modules and models and I really don't see an errors
in syntax at this point so I'm stumped. Any ideas or input would be
awesome.
> > with auto increment keys.- Hide quoted text -

Sabin, Mihaela

unread,
May 2, 2011, 8:05:02 AM5/2/11
to cis...@googlegroups.com
Scott, Matt, Brice, and Aaron,

dbInstall.php must have a "set storage_engine = InnoDB" query applied to the database after the database has been created. Otherwise, the foreign key constraints wont't work. See dbInstall.php in cis605-donate project in Google Code (I made a commit a few minutes ago).

Each time we run dbInstallSandbox.php, we must run dbInstall.php first.

Be very careful with foreign keys. Their values must exist in the parent table.

mysql_insert_id( ) works only for auto_increment keys. If a key is a both a primary key AND a foreign key, then mysql_insert_id( ) does not work. This is because such key does not have auto_increment in its definition.

Finally, I added functions in dbIndividual.php (donate project) and Individual to be called in dbInstallSandbox.php and produce an output of what exactly was inserted in the database. This is a model that can be used for any other table. Note that Individual table does not have an auto_increment primary key. In the case of the tables with an auto_increment primary key, mysql_insert_id( ) must be used instead of hard coded numerical values.


> -----Original Message-----
> From: cis...@googlegroups.com [mailto:cis...@googlegroups.com] On

Brice Rader

unread,
May 2, 2011, 4:41:09 PM5/2/11
to cis...@googlegroups.com
so if comparing the two projects, is individual in donate, opportunity in i2c?

Matt Edmonds

unread,
May 2, 2011, 5:36:19 PM5/2/11
to cis...@googlegroups.com
Individual is in Donate project, yes.

Brice Rader

unread,
May 2, 2011, 5:58:37 PM5/2/11
to cis...@googlegroups.com
yeah i know that, i'm trying to figure out which table in my project would be equivalent and i think it's opportunity.

Scott

unread,
May 2, 2011, 8:12:41 PM5/2/11
to cis605
I fixed dbInstall, and that works, and I can verify in command. The
Install still won't work. Adding the id function will be easy enough
once the file works. If I run dbinstall, and then run sandbox (with
usertype, username, and userpros couns commented out) the file runs,
but there is just blank values in the counselingStatus and type tables
(when I check command). I'm commiting now, but didn't know if anyone
had any input. I commented out the bad my_sql_id calls in the db
files, and the getters and setters in the class files seem correct,
along with the insertInto functions.

On May 2, 5:58 pm, Brice Rader <hockeybp...@gmail.com> wrote:
> yeah i know that, i'm trying to figure out which table in my project would
> be equivalent and i think it's opportunity.
>
>
>
> On Mon, May 2, 2011 at 5:36 PM, Matt Edmonds <edmond...@gmail.com> wrote:
> > Individual is in Donate project, yes.- Hide quoted text -

Scott

unread,
May 2, 2011, 8:46:38 PM5/2/11
to cis605
I was looking at Donate changes and I realized that I forgot the
__construct. This fixed the problem for all but UserProsCouns. The
rest work and update with the correct information, and there are no
more empty sets. I can't for the life of me figure out why
userProsCouns won't work still.
> > - Show quoted text -- Hide quoted text -

Sabin, Mihaela

unread,
May 2, 2011, 8:59:17 PM5/2/11
to cis...@googlegroups.com
Another error I found in Donate, Scott, was that the 'getter' functions for one class didn't use camel case while the calls to those getters did.

> -----Original Message-----
> From: cis...@googlegroups.com [mailto:cis...@googlegroups.com] On
> Behalf Of Scott
> Sent: Monday, May 02, 2011 8:47 PM
> To: cis605

Scott

unread,
May 2, 2011, 10:15:02 PM5/2/11
to cis605
Good thinking....wasn't the problem though...Still not working.
Reply all
Reply to author
Forward
0 new messages