Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.2.3

Bug #7909 nextID broken, prevents records from saving
Submitted: 2006-06-15 16:39 UTC
From: julieatwork at sethandjulie dot net Assigned: quipo
Status: Closed Package: MDB_QueryTool (version 1.1.1)
PHP Version: 4.4.2 OS: debian
Roadmaps: (Not assigned)    

 [2006-06-15 16:39 UTC] julieatwork at sethandjulie dot net (julie)
Description: ------------ The line in query.php: (int)$this->db->nextId($this->sequenceName) gives me the error message "InnoDB is not a supported table type by this MySQL database server" if I remove the int and echo "$this->db->nextId($this->sequenceName)". Echoing $this->sequenceName by itself works fine; the problem is definitely with the nextId part. I saw there was a bug on the MDB2 bug reports about a similar issue, but Ergo, the simple sample script ( fails out-of-the-box. Presumably this has something to do with my particular setup (else it would have been discovered already), but all the other methods seem to work, and the message itself is confusing, because my table definitely has a primary key (id) and it is set to auto_increment. I'm using MDB2 and MySQL. Test script: --------------- $data = array( 'name' => 'this is a name', 'dgroup'=> 14 ); $newCarId = $car->save($data); var_dump($newCarId); Expected result: ---------------- The id returned from the new row. Actual result: -------------- It returns false, but if I remove the (int) declaration, it gives me the above error message, and if I modify Query.php to comment out these lines (around 649), it works perfectly: $id = (int)$this->db->nextId($this->sequenceName); $newData[$this->primaryCol] = $id; The only problem with this "solution" is that then if you try to update a row that doesn't exist with "save" (i.e., specify an id that is assigned to no row), it still returns true, even though it does absolutely nothing.


 [2006-06-15 16:41 UTC] julieatwork at sethandjulie dot net
Er, goodness, I didn't finish my sentence in that first part. I meant to say that the problem in MDB2 has supposedly been fixed, and I am using the most recent version (including the fix).
 [2006-06-15 16:52 UTC] julieatwork at sethandjulie dot net
It also seems to fix it if you change the capitalization of nextId to nextID. Any consequences to that for elsewhere?
 [2006-06-15 17:07 UTC] quipo (Lorenzo Alberton)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. You're right, the method is called differently in MDB and MDB2: nextId() in the former, nextID() in the latter. Please grab the CVS version, I committed a fix.
 [2006-06-15 20:37 UTC] julieatwork at sethandjulie dot net
I updated with the fix, but it's still not working on my system, unfortunately. Now it gives me the message "nextID: on demand sequence dealerships could not be created" where dealerships is my table name. It also says "MDB2 Error: not supported" and "INNODB is not a supported table type by this MySQL database server[Native code: 0]". This happens only when I'm trying to ADD -- updating a row works perfectly. This is still on the same code example.
 [2006-06-17 09:44 UTC] quipo (Lorenzo Alberton)
are you *sure* that you're using an InnoDB engine? try with: SHOW VARIABLES LIKE 'have_inno%' if it's DISABLED, then you don't have an InnoDB table. @see,53946,54829#msg-54829
 [2006-06-19 12:38 UTC] julieatwork at sethandjulie dot net
No, it's not InnoDB, it's MyISAM -- sorry I didn't clarify that to begin with. But why would InnoDB be required for simply *saving* rows? Didn't see that in the docs anywhere. And if I comment those lines out (in my earlier post) then it works fine. Sorry if I'm confused.
 [2006-06-19 13:40 UTC] julieatwork at sethandjulie dot net
Just in case, I changed my table type to InnoDB, ran the query you asked (it returned YES), and tried again -- and got the exact same error message.
 [2006-06-19 14:02 UTC] julieatwork at sethandjulie dot net
Downloaded the CVS of MDB2, and something seems to have fixed it.
 [2006-06-19 14:02 UTC] julieatwork at sethandjulie dot net
see above
 [2006-06-19 14:07 UTC] quipo (Lorenzo Alberton)
> Downloaded the CVS of MDB2, > and something seems to have fixed it I was about to suggest that, since I couldn't reproduce your issue... well, I'm glad everything's fine, now.
 [2006-07-31 17:30 UTC] benjaminhill at gmail dot com (Benjamin)
I ran into the same thing - for anyone that sees this, I SUSPECT it has to do with the fact that my service provider doesn't allow InnoDB tables, everything is only MyISAM. So, when it tries to create the new sequence for the on-demand table, it bombs. Upgrading to the latest (not in CVS) fixed the problem.