Php 使用PDO调用具有相同名称的存储过程
我的数据库Postgres中有两个存储过程,它们都有相同的名称,但不同的是参数 过程1(::字符串,::整数,::字符串,::整数) 过程1(::字符串,::整数,::整数) 在PDO中,doing bindParam correct是STR,INT,INT,但是prepree总是执行过程1 我怎样才能让他明白我所说的程序 需要更多帮助的信息?我明白了吗?谢谢 编辑===Php 使用PDO调用具有相同名称的存储过程,php,pdo,procedure,Php,Pdo,Procedure,我的数据库Postgres中有两个存储过程,它们都有相同的名称,但不同的是参数 过程1(::字符串,::整数,::字符串,::整数) 过程1(::字符串,::整数,::整数) 在PDO中,doing bindParam correct是STR,INT,INT,但是prepree总是执行过程1 我怎样才能让他明白我所说的程序 需要更多帮助的信息?我明白了吗?谢谢 编辑=== 它给出的错误是,他正在运行一个需要四个参数的过程尝试更改$query语句以显式地告诉PDO类型,并避免额外的代码切换到b
它给出的错误是,他正在运行一个需要四个参数的过程尝试更改
$query
语句以显式地告诉PDO类型,并避免额外的代码切换到bindValue
(PDO使用PARAM标志格式化SQL,而不是转换数据类型):
请展示你的具体代码。PDO甚至支持postgres的存储过程重载吗?
$bounds = null; // forced for debug
if(!is_null($bounds)){
$query = "SELECT procedure1(:name, :domain, :geo, :userid)";
$stmt = $db->prepare($query);
$stmt->bindParam('name', $name, PDO::PARAM_STR);
$stmt->bindParam('domain', $idDomain, PDO::PARAM_INT);
$stmt->bindParam('geo', $geoString, PDO::PARAM_STR);
$stmt->bindParam('userid', $userId, PDO::PARAM_INT);
}else{
$query = "SELECT procedure1(:name, :domain, :userid)";
$stmt = $db->prepare($query);
$stmt->bindParam('name', $name, PDO::PARAM_STR);
$stmt->bindParam('domain', $idDomain, PDO::PARAM_INT);
$stmt->bindParam('userid', $userId, PDO::PARAM_INT);
}
$result = $stmt->execute();
$bounds = null; // forced for debug
if(!is_null($bounds)){
$query = "SELECT procedure1(:name::VARCHAR, :domain::INTEGER, :geo::VARCHAR, :userid::INTEGER)";
$stmt = $db->prepare($query);
$stmt->bindValue('name', $name);
$stmt->bindValue('domain', $idDomain);
$stmt->bindValue('geo', $geoString);
$stmt->bindValue('userid', $userId);
}else{
$query = "SELECT procedure1(:name::VARCHAR, :domain::INTEGER, :userid::INTEGER)";
$stmt = $db->prepare($query);
$stmt->bindValue('name', $name);
$stmt->bindValue('domain', $idDomain);
$stmt->bindValue('userid', $userId);
}
$result = $stmt->execute();