1

I have 2 custom content type 'Movie' and 'Director';

In the Movie type there is a field that refers to some Director type.

Now , when i try to create a Movie content type it generates the following error.But the site admin can successfully create Movies.

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'nid' in where clause is ambiguous: SELECT DISTINCT node.nid AS entity_id, node.vid AS revision_id, node.type AS bundle, :entity_type AS entity_type FROM {node} node INNER JOIN {node_access} na ON na.nid = node.nid WHERE (nid IN (:db_condition_placeholder_0)) AND (type IN (:db_condition_placeholder_1)) AND(( (na.gid = :db_condition_placeholder_2) AND (na.realm = :db_condition_placeholder_3) )OR( (na.gid = :db_condition_placeholder_4) AND (na.realm = :db_condition_placeholder_5) ))AND (na.grant_view >= :db_condition_placeholder_6) ; Array ( [:db_condition_placeholder_0] => 2 [:db_condition_placeholder_1] => writer [:db_condition_placeholder_2] => 0 [:db_condition_placeholder_3] => all [:db_condition_placeholder_4] => 32 [:db_condition_placeholder_5] => user_relationship_node_access_author [:db_condition_placeholder_6] => 1 [:entity_type] => node ) in EntityFieldQuery->execute() (line 1136 of /home/mysite/public_html/includes/entity.inc).

I solved the problem .In /public_html/includes/entity.inc I changed

$this->addCondition($select_query,$sql_field, $this->entityConditions['entity_id']);

to

$this->addCondition($select_query,"$base_table.".$sql_field, $this->entityConditions['entity_id']);

this statement should be somewhere near of line 1207

2

The reason is here:

[…] ON na.nid = node.nid WHERE (nid IN (:db_condition_placeholder_0)) […]

Can you see the nid after the WHERE keyword, it has no identifier and therefore PDO does not know how to handle it. You must prefix it with the correct table name (or assigned shortcut). Either na.nid or node.nid should do the trick.

  • I understand what you said, but i cant find any query related to nid in /home/mysite/public_html/includes/entity.inc could you tell me where to find the php statements that builds the problematic query ?? – Azad Salam Apr 23 '12 at 9:09
  • The query must be created within any function that is called while creating the form for your content type. Are you using any special modules, anything in your theme? It's nearly impossible to help you here because one would need access to your Drupal installation to debug this. – Fleshgrinder Apr 23 '12 at 9:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.