Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
PDOStatement===FALSE: help?
Linc
Admin
In my vBulletin importer, I've got an SQL query that maps old usergroup IDs to their new RoleIDs and inserts the new relationships in GDN_UserRole.
If I truncate the GDN_UserRole table, I can run the query fine in phpmyadmin. If I try to run it through Garden, it throws this error:
So $PDOStatement === FALSE after the query for some reason. However, if I open up the database, it shows that it has, in fact, put 5,627 rows into the GDN_UserRole table. Running the query manually produces 5,642 records with no error. If I check the results after running it manually, the pair 1-16 only shows up one time.
What am I doing wrong?
If I truncate the GDN_UserRole table, I can run the query fine in phpmyadmin. If I try to run it through Garden, it throws this error:
FATAL ERROR IN: Gdn_Database.Query();
"Duplicate entry '1-16' for key 1"
insert into GDN_UserRole (UserID, RoleID)
select u.userid, r.RoleID
from vb_user u
inner join GDN_Role r
on u.usergroupid = r.VbulletinImportID
LOCATION: /storage/websites/forum.icrontic.com/library/database/class.database.php
> 212: }
> 213:
> 214: if ($PDOStatement === FALSE) {
> 215: trigger_error(ErrorMessage($this->GetPDOErrorMessage($this->Connection()->errorInfo()), $this->ClassName, 'Query', $Sql), E_USER_ERROR);
> 216: }
So $PDOStatement === FALSE after the query for some reason. However, if I open up the database, it shows that it has, in fact, put 5,627 rows into the GDN_UserRole table. Running the query manually produces 5,642 records with no error. If I check the results after running it manually, the pair 1-16 only shows up one time.
What am I doing wrong?
0
Comments
select distinct u.userid, r.RoleID from vb_user u inner join GDN_Role r on u.usergroupid = r.VbulletinImportID
FATAL ERROR IN: Gdn_Database.Query(); "Duplicate entry '1-16' for key 1" insert into GDN_UserRole (UserID, RoleID) select distinct u.userid, r.RoleID from vb_user u inner join GDN_Role r on u.usergroupid = r.VbulletinImportID LOCATION: /storage/websites/forum.icrontic.com/library/database/class.database.php > 210: $PDOStatement = $this->Connection()->query($Sql); > 211: } > 212: > 213: if ($PDOStatement === FALSE) { >>> 214: trigger_error(ErrorMessage($this->GetPDOErrorMessage($this->Connection()->errorInfo()), $this->ClassName, 'Query', $Sql), E_USER_ERROR); > 215: }
</
1 16 4 32 5 16 6 8 7 16 8 8
The imported data set begins like this:
0 2 1 16 6 8 8 8 9 8 10 8
Which is clearly wrong, because there is no user with ID #0, and members 4, 5, and 7 have disappeared. Not only is it throwing an error, it's executing the query with a different result. (Yes, both sets were ordered by UserID)This smells like a day destroyer. Going to go put the kettle on and buckle down.
<?php if (!defined('APPLICATION')) exit(); class TestController extends GardenController { public function Index() { $Database = Gdn::Database(); $PDO = $Database->Connection(); $Construct = $Database->Structure(); $SQL = $Database->SQL(); $Database->Query("insert into GDN_UserRole (UserID, RoleID) select userid, roleid from ben_test"); echo "Done."; exit; } }
A quick Google and a look around StackOverflow suggests that it can be caused by a corrupt table. Have you tried doing a repair on the table or rebuilding your database (SQL dump out -> then recreate)?
Maybe try to SELECT all the data in the GDN_UserRole table, loop through it all and write it a dummy text file in the /cache folder just to make sure something else isnt sticking records in there before your INSERT query runs?
This was also the core of FoxyFred's Vanilla import problem too.