0

When I try to execute this Sql-Statement I have this error :

*Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1052 Column 'id_actualite' in where clause is ambiguous' in C:\wamp\www\contradictors\library\Zend\Db\Statement\Pdo.php on line 234*

Here is my code :

    <?php
        class Critique extends Zend_Db_Table
        {
             protected $_name = "Critique" ;

             public function select_critique($limit1, $limit2)
             {
                   $db = $this -> getDefaultAdapter() ;
                   $last_actu = $db -> select()
                                    -> order('id_actualite DESC')
                                    -> from('Actualite')
                                    -> limit($limit1) ;
                   $last_actu = $last_actu -> query() ;
                   $last_actu = $last_actu -> fetch() ;

                   $select = $db -> select()
                                 -> from('Critique')
                                 -> order('id_critique DESC')
                                 -> join('Actualite', 'Critique.id_actualite = Actualite.id_actualite')
                                 -> where('id_actualite = ' . $last_actu['id_actualite'])
                                 -> limit($limit2) ;
                  return $select -> query() ;
             }
        }
   ?>

I don't have any idea about this error :( thank you

1 Answer 1

2

You have two columns named id_actualite: Critique.id_actualite and Actualite.id_actualite, so the where clause

where('id_actualite = ' . $last_actu['id_actualite'])

is ambiguous. Try changing it to

where('Critique.id_actualite = ' . $last_actu['id_actualite'])

or

where('Actualite.id_actualite = ' . $last_actu['id_actualite'])
Sign up to request clarification or add additional context in comments.

1 Comment

@Mehdi Your welcome. Please accept the answer if it works. Accepting and upvoting are the usual ways of thanking.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.