Skip to main content
Topic: Classic 2.7.3 - AccountController.php have id bug (Read 1044 times) previous topic - next topic

Classic 2.7.3 - AccountController.php have id bug

Hello,
 \AccountController.php  have bug with id if you join some other tables into account that have column id too (in my case it is table teams).
This error happens in this case:
SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous
Stack:
...
3 C:\Apps\xampp\htdocs\titanquest\app\controllers\AccountController.php(43): PDODb->getOne('users', Array)
...

Problem is in function index()) line with where:
Code: [Select]
	function index(){
$db = $this->GetModel();
$rec_id = $this->rec_id = USER_ID; //get current user id from session
$db->where ("id", $rec_id);
$tablename = $this->tablename;
$fields = array("users.id",
"users.login_name",
"users.fullname",
...              

Column in where do not contains name of the table - this is the bug.  Solution is simple - add tablename and it is working:
Code: [Select]
$db->where ("users.id", $rec_id);

Please fix this bug - manula fixing remove AccountController.php from publishing and that is not too good.

Re: Classic 2.7.3 - AccountController.php have id bug

Reply #1
Thank you! This solved the "SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id' in where clause is ambiguous" error I was getting.

I hope it'll be fixed in the next release of PHPRad  ;)

Re: Classic 2.7.3 - AccountController.php have id bug

Reply #2
it didn't work for me.

i'm trying to create a master/detail relation.

i'm not sure if this is happening because of a 1 to N relation between users and roles tables.

users.idrole = roles.idrole

I just want to display all the users that belong to certain role.

hope you can help me.

thanks!