From: James Stewart on
Hi,

I'm using DB_DO_FB for a conference management system which includes
four tables:

conference_session
conference_time_slots
conference_venues
conference_session_time_slot

The final table, conference_session_time_slot, connects a session
with a time slot and a venue, and I have my conference_session DO set
up with:

public $fb_crossLinks = array(
'table' => 'conference_session_time_slot',
'fromField' => 'session_id',
'toField' => 'time_slot'));

and in my conference_session_time_slot I have:

public $fb_crossLinkExtraFields = array('location');

That generates a form with checkboxes for each time slot, and a
select list of venues for each time slot. When I add a session to a
new time slot everything works fine, with an entry being created for
the appropriate time slot and location, but when I try to alter a
location for an already selected time slot the update isn't completed
and DB_DO_FB attempts to insert a new value in the database for just
the location. eg.


DataObjects_Conference_session_time_slot: QUERY: INSERT INTO
conference_session_time_slot (location ) VALUES ( 6 )

where 6 is the value of the location I want to change to, but I
expect something like:

UPDATE conference_session_time_slot SET location = 6 WHERE id = X


Looking through the code I can't see where DB_DO_FB actually works
out which updates it's supposed to make for extra fields, so I'm not
sure where to go next. Anyone got any ideas?

thanks. James.

--
James Stewart
http://jystewart.net/process/
From: "Justin Patrin" on
On 9/22/06, James Stewart <lists(a)jystewart.net> wrote:
> Hi,
>
> I'm using DB_DO_FB for a conference management system which includes
> four tables:
>
> conference_session
> conference_time_slots
> conference_venues
> conference_session_time_slot
>
> The final table, conference_session_time_slot, connects a session
> with a time slot and a venue, and I have my conference_session DO set
> up with:
>
> public $fb_crossLinks = array(
> 'table' => 'conference_session_time_slot',
> 'fromField' => 'session_id',
> 'toField' => 'time_slot'));
>
> and in my conference_session_time_slot I have:
>
> public $fb_crossLinkExtraFields = array('location');
>
> That generates a form with checkboxes for each time slot, and a
> select list of venues for each time slot. When I add a session to a
> new time slot everything works fine, with an entry being created for
> the appropriate time slot and location, but when I try to alter a
> location for an already selected time slot the update isn't completed
> and DB_DO_FB attempts to insert a new value in the database for just
> the location. eg.
>
>
> DataObjects_Conference_session_time_slot: QUERY: INSERT INTO
> conference_session_time_slot (location ) VALUES ( 6 )
>
> where 6 is the value of the location I want to change to, but I
> expect something like:
>
> UPDATE conference_session_time_slot SET location = 6 WHERE id = X
>
>
> Looking through the code I can't see where DB_DO_FB actually works
> out which updates it's supposed to make for extra fields, so I'm not
> sure where to go next. Anyone got any ideas?
>

Almost certainly you didn't set up your primary key on the
conference_session_time_slot correctly.

--
Justin Patrin
From: James Stewart on
On Sep 22, 2006, at 7:48 PM, Justin Patrin wrote:
> On 9/22/06, James Stewart <lists(a)jystewart.net> wrote:
<snip>
>> That generates a form with checkboxes for each time slot, and a
>> select list of venues for each time slot. When I add a session to a
>> new time slot everything works fine, with an entry being created for
>> the appropriate time slot and location, but when I try to alter a
>> location for an already selected time slot the update isn't completed
>> and DB_DO_FB attempts to insert a new value in the database for just
>> the location. eg.
>>
>>
>> DataObjects_Conference_session_time_slot: QUERY: INSERT INTO
>> conference_session_time_slot (location ) VALUES ( 6 )
>>
>> where 6 is the value of the location I want to change to, but I
>> expect something like:
>>
>> UPDATE conference_session_time_slot SET location = 6 WHERE id = X
>>
>>
>> Looking through the code I can't see where DB_DO_FB actually works
>> out which updates it's supposed to make for extra fields, so I'm not
>> sure where to go next. Anyone got any ideas?
>>
>
> Almost certainly you didn't set up your primary key on the
> conference_session_time_slot correctly.

It's definitely declared as a primary key in the schema and the DO
seems to have picked it up. Is there somewhere else I should be
declaring it?

The table definition is (I'm using MySQL):

------
CREATE TABLE `conference_session_time_slot` (
`id` int(11) NOT NULL auto_increment,
`session_id` int(11) default NULL,
`time_slot` int(11) NOT NULL default '0',
`location` int(11) default NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM;
------

The do's .ini file holds:

------
[conference_session_time_slot]
id = 129
session_id = 129
time_slot = 129
location = 1
------

and the first few lines of the DO class are:

------
class DataObjects_Conference_session_time_slot extends DB_DataObject
{
###START_AUTOCODE
/* the code below is auto generated do not remove the above tag */

var $__table = 'conference_session_time_slot'; // table name
var $id; // int(11) not_null
primary_key auto_increment
var $session_id; // int(11) not_null
var $time_slot; // int(11) not_null
var $location; // int(11)
------

thanks. James.
From: Ian Warner on
James Stewart wrote:
> On Sep 22, 2006, at 7:48 PM, Justin Patrin wrote:
>> On 9/22/06, James Stewart <lists(a)jystewart.net> wrote:
> <snip>
>>> That generates a form with checkboxes for each time slot, and a
>>> select list of venues for each time slot. When I add a session to a
>>> new time slot everything works fine, with an entry being created for
>>> the appropriate time slot and location, but when I try to alter a
>>> location for an already selected time slot the update isn't completed
>>> and DB_DO_FB attempts to insert a new value in the database for just
>>> the location. eg.
>>>
>>>
>>> DataObjects_Conference_session_time_slot: QUERY: INSERT INTO
>>> conference_session_time_slot (location ) VALUES ( 6 )
>>>
>>> where 6 is the value of the location I want to change to, but I
>>> expect something like:
>>>
>>> UPDATE conference_session_time_slot SET location = 6 WHERE id = X
>>>
>>>
>>> Looking through the code I can't see where DB_DO_FB actually works
>>> out which updates it's supposed to make for extra fields, so I'm not
>>> sure where to go next. Anyone got any ideas?
>>>
>>
>> Almost certainly you didn't set up your primary key on the
>> conference_session_time_slot correctly.
>
> It's definitely declared as a primary key in the schema and the DO
> seems to have picked it up. Is there somewhere else I should be
> declaring it?
>
> The table definition is (I'm using MySQL):
>
> ------
> CREATE TABLE `conference_session_time_slot` (
> `id` int(11) NOT NULL auto_increment,
> `session_id` int(11) default NULL,
> `time_slot` int(11) NOT NULL default '0',
> `location` int(11) default NULL,
> PRIMARY KEY (`id`)
> ) TYPE=MyISAM;
> ------
>
> The do's .ini file holds:
>
> ------
> [conference_session_time_slot]
> id = 129
> session_id = 129
> time_slot = 129
> location = 1
> ------
Should also be underneath this :

[conference_session_time_slot__keys]
id = N

Also check for spelling mistakes in keys and fields if hand done - this
has got me a a few times.
>
> and the first few lines of the DO class are:
>
> ------
> class DataObjects_Conference_session_time_slot extends DB_DataObject
> {
> ###START_AUTOCODE
> /* the code below is auto generated do not remove the above tag */
>
> var $__table = 'conference_session_time_slot'; // table name
> var $id; // int(11) not_null
> primary_key auto_increment
> var $session_id; // int(11) not_null
> var $time_slot; // int(11) not_null
> var $location; // int(11)
> ------
>
> thanks. James.
>
> --PEAR General Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
From: James Stewart on
On Sep 22, 2006, at 9:10 PM, Ian Warner wrote:
> James Stewart wrote:
>> On Sep 22, 2006, at 7:48 PM, Justin Patrin wrote:
>>> On 9/22/06, James Stewart <lists(a)jystewart.net> wrote:
>> <snip>
>>>> That generates a form with checkboxes for each time slot, and a
>>>> select list of venues for each time slot. When I add a session to a
>>>> new time slot everything works fine, with an entry being created
>>>> for
>>>> the appropriate time slot and location, but when I try to alter a
>>>> location for an already selected time slot the update isn't
>>>> completed
>>>> and DB_DO_FB attempts to insert a new value in the database for
>>>> just
>>>> the location. eg.
>>>>
>>>>
>>>> DataObjects_Conference_session_time_slot: QUERY: INSERT INTO
>>>> conference_session_time_slot (location ) VALUES ( 6 )
>>>>
>>>> where 6 is the value of the location I want to change to, but I
>>>> expect something like:
>>>>
>>>> UPDATE conference_session_time_slot SET location = 6 WHERE id = X
>>>>
>>>>
>>>> Looking through the code I can't see where DB_DO_FB actually works
>>>> out which updates it's supposed to make for extra fields, so I'm
>>>> not
>>>> sure where to go next. Anyone got any ideas?
>>>>
>>>
>>> Almost certainly you didn't set up your primary key on the
>>> conference_session_time_slot correctly.
>>
>> It's definitely declared as a primary key in the schema and the DO
>> seems to have picked it up. Is there somewhere else I should be
>> declaring it?
>>
>> The table definition is (I'm using MySQL):
>>
>> ------
>> CREATE TABLE `conference_session_time_slot` (
>> `id` int(11) NOT NULL auto_increment,
>> `session_id` int(11) default NULL,
>> `time_slot` int(11) NOT NULL default '0',
>> `location` int(11) default NULL,
>> PRIMARY KEY (`id`)
>> ) TYPE=MyISAM;
>> ------
>>
>> The do's .ini file holds:
>>
>> ------
>> [conference_session_time_slot]
>> id = 129
>> session_id = 129
>> time_slot = 129
>> location = 1
>> ------
> Should also be underneath this :
>
> [conference_session_time_slot__keys]
> id = N
>
> Also check for spelling mistakes in keys and fields if hand done -
> this has got me a a few times.

It was auto-generated, and the keys entry is as shown.

thanks. James.