Bonjour,
Dans mon projet, je suis passé de creole à PDO (upgrade de symfony 0.6 à symfony 1.2).
Avec creole, je faisais ça :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| $con = Propel::getConnection(); // connect to database
$query = "select * from f_get_global_param_value_text(?, ?, ?, ?)";
$stmt = $con->prepareStatement( $query );
$stmt->setInt( 1, $groupeAgenceId );
$stmt->setInt( 2, $agenceId );
$stmt->setInt( 3, $employeeId );
$stmt->setString( 4, $paramName );
try
{
$rs = $stmt->executeQuery();
}
catch (SQLException $sql_exception)
{
return null;
}
if ( $rs->next() )
{
$paramValue = $rs->getString( "f_get_global_param_value_text" );
}
else
{
return null;
}
return $paramValue; |
Maintenant, j'ai du adapter comme ça :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| $con = Propel::getConnection(); // connect to database
$query = "select * from f_get_global_param_value_text(?, ?, ?, ?)";
$stmt = $con->prepare( $query );
$stmt->bindValue( 1, $groupeAgenceId );
$stmt->bindValue( 2, $agenceId );
$stmt->bindValue( 3, $courtierId );
$stmt->bindValue( 4, $paramName );
try
{
$stmt->execute();
}
catch (PDOException $sql_exception)
{
return null;
}
if ( $rs->next() )
{
$paramValue = $rs->getString( "f_get_global_param_value_text" );
}
else
{
return null;
}
return $paramValue; |
Mais ça ne marche pas, voilà ce que j'obtiens comme erreur dans $sql_exception :
Ambiguous function: 7 ERROR: function f_get_global_param_value_text(unknown, unknown, unknown, unknown) is not unique
Le problème, c'est que dans la base j'ai plusieurs fonctions du même nom avec des signatures différentes :
f_get_global_param_value_text(p_key_level character varying, p_key_id character varying, p_param_nom character varying, p_parameter character varying[])
f_get_global_param_value_text(p_groupe_agence_id integer, p_agence_id integer, p_courtier_id integer, p_param_nom character varying)
f_get_global_param_value_text(p_key_level character varying, p_key_id character varying, p_param_nom character varying)
Là, en l'occurence, c'est la deuxième qui devrait être appelée.
J'ai essayé ça :
1 2 3 4
| $stmt->bindValue( 1, $courtier->getAgence()->getGroupeAgence()->getId(), PDO::PARAM_INT );
$stmt->bindValue( 2, $courtier->getAgence()->getId(), PDO::PARAM_INT );
$stmt->bindValue( 3, $courtier->getId(), PDO::PARAM_INT );
$stmt->bindValue( 4, $paramName, PDO::PARAM_STR ); |
et ça :
1 2 3 4
| $stmt->bindValue( 1, (int)$courtier->getAgence()->getGroupeAgence()->getId(), PDO::PARAM_INT );
$stmt->bindValue( 2, (int)$courtier->getAgence()->getId(), PDO::PARAM_INT );
$stmt->bindValue( 3, (int)$courtier->getId(), PDO::PARAM_INT );
$stmt->bindValue( 4, (string)$paramName, PDO::PARAM_STR ); |
mais ça ne change rien...
Je ne suis pas sûr de comprendre où est le problème.
Comment faire sans modifier ce qu'il y a dans postgres ?
Merci d'avance
Partager