I know this seems very unlikely, and it's probably just me, but:

In the hook_insert of a new module I have this line:

db_query("INSERT INTO {zone} (vid, nid, zone_pnid, zone_root, zone_rank, zone_weight) VALUES (%d, %d, %d, %d, %d, %d)", $node->vid, $node->nid, $node->zone_pnid, $node->zone_root, $node->zone_rank, $node->zone_weight);

The value of zone_pnid is zero when the node is created, but examination of my 'zone' table shows zone_pnid as being given the value of $node->nid instead, or possibly $node->vid as they are the same.

I have thoroughly tested this. I have used a different variable, used a constant value and so on. I have decoupled the value to be written from the value in the node. And every time: When the value to be inserted is zero it becomes the previous variable's value, and when it is non-zero it is stored as the correct value. I even tried changing the third %d to %s, but the result was the same.

This is the MySQL definition for the table:

--
-- Table structure for table `ob_zone`
--

CREATE TABLE `ob_zone` (
  `vid` int(10) NOT NULL default '0',
  `nid` int(10) NOT NULL default '0',
  `zone_pnid` int(10) NOT NULL default '0',
  `zone_root` int(10) NOT NULL default '0',
  `zone_rank` int(10) NOT NULL default '-10000',
  `zone_weight` int(10) NOT NULL default '0',
  PRIMARY KEY  (`vid`),
  KEY `zone_pnid` (`zone_pnid`),
  KEY `zone_rank` (`zone_rank`),
  KEY `zone_root` (`zone_root`),
  KEY `nid` (`nid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

It seems hard to believe this is a db_query error (it tends to get used a lot) but just in case...

(I'm using PHP 5.2.5 and MySQL 5.0.45 -- and I'm not a newbie, but everyone can make mistakes.)

Comments

dpearcefl’s picture

Status: Active » Closed (won't fix)

Considering the time elapsed between now and the last comment plus the fact that D5 is no longer supported, I am closing this ticket.

dpearcefl’s picture

Status: Closed (won't fix) » Postponed

Going to open this issue until I can confirm it doesn't exist in modern Drupal.

codi’s picture

Status: Postponed » Closed (won't fix)

old issue and drupal 5 is no longer supported.