好的,所以这段代码在过去一天左右给我带来了麻烦。它的所有职责都工作得很好,除了税务查询。(至少那是我能说出的唯一给我带来麻烦的人)……据我所知;该代码给我带来了麻烦,因为它们是多个相同的 TUID 和 UID,但不要转到同一个用户,(例如 == 1 的 ID 可能是 User1 或可能是 Group1)。
我不是要求你们修复这段代码,(似乎每次我在这里发帖时,有人说'哦,你只是想让我们修复你的代码,等等等等等等')我只是好奇是否有人有一个好的解决这个问题?
我将重复的行返回到查询中;这是查询返回的内容:http: //gmz1023.com/rowline.PNG
{
$sql = "SELECT type FROM bank_transaction LIMIT 25";
$que = $this->db->prepare($sql);
$que->bindParam('uid', $uid);
try{
$que->execute();
ob_start();
if($que)
{
$id = '1';
$transaction = '';
while($row = $que->fetch())
{
/* This is the tricky bit; for each type that is returned, we start another query and pull up that data.<
/* This may need to be turned into seperate functions later on. however, for now, keep trying to figure out how to get the code to work,
/* There's nor eason why it shouldn't work, as its simple as hell. and yet we keep getting multiple rows in the table.
*/
if($row[0] == 'govt')
{
$sql = "SELECT tuid, uid, balance FROM bank_transaction WHERE type = :type AND uid = :uid";
$querty1 = $this->db->prepare($sql);
$type = 'govt';
$querty1->bindParam('type', $type);
$querty1->bindParam('type', $row[0]);
$querty1->bindParam('uid', $uid);
try {
if($querty1->execute())
{
$info = $querty1->fetch();
$to = parent::getUsername($info[0]);
$from = parent::getStoryName($info[1]);
$balance = $info[2];
$transaction .= "<tr><td>{$id}</td><td>{$from}</td><td>{$to}</td><td>{$balance}</td><td>{$row[0]}</td></tr>";
$querty1->closeCursor();
}
}catch(PDOException $e) { echo $e->getMessage();}
}
if($row[0] == 'business')
{
$sql = "SELECT tuid, uid, balance, date FROM bank_transaction WHERE type = :type AND tuid = :uid OR uid = :uid";
$querty1 = $this->db->prepare($sql);
$type = 'business';
$querty1->bindParam('type', $type);
$querty1->bindParam('type', $row[0]);
$querty1->bindParam('uid', $uid);
try {
if($querty1->execute())
{
$info = $querty1->fetch();
$to = $info[0];
$from = $info[1];
$balance = $info[2];
$date = $info[3];
$transaction .= "<tr><td>{$id}</td><td>{$from}</td><td>{$to}</td><td>{$balance}</td><td>{$row[0]}</td><td>{$info[3]}</tr>";
$querty1->closeCursor();
}
}catch(PDOException $e) { echo $e->getMessage();}
}
if($row[0] == 'tax')
{
$sql = "SELECT tuid, uid, balance, date FROM bank_transaction WHERE tuid = :tuid AND type = :type ;";
$querty = $this->db->prepare($sql);
$type = 'tax';
$uid = '2';
$querty->bindParam('type', $type);
$querty->bindParam('tuid', $uid);
try {
if($querty->execute())
{
$info = $querty->fetch();
$to = parent::getStoryName($info[0]);
$from = parent::getUsername($info[1]);
$balance = $info[2];
$transaction .= "<tr><td>{$id}</td><td>{$from}</td><td>{$to}</td><td>{$balance}</td><td>{$row[0]}</td><td>{$info[3]}</tr>";
$querty->closeCursor();
}
}catch(PDOException $e) { echo $e->getMessage();}
}
elseif($row[0] == 'personal')
{
$sql = "SELECT tuid, uid, balance FROM bank_transaction WHERE type = :type AND uid = :uid OR tuid = :uid";
$querty = $this->db->prepare($sql);
$type = 'personal';
$querty->bindParam('type', $type);
$queryt->bindParam('uid', $uid);
try {
if($querty->execute())
{
$info = $querty->fetch();
$to = $info[0];
$from = $info[1];
$balance = $info[2];
$transaction .= "<tr><td>{$id}</td><td>{$from}</td><td>{$to}</td><td>{$balance}</td><td>{$row[0]}</td></tr>";
$querty->closeCursor();
}
}catch(PDOException $e) { echo $e->getMessage();}
}
$id = $id +1;
}
return $transaction;
ob_end_clean();
}
else
{
echo "ERROR!";
}
}catch(PDOException $e) { echo $e->getMessage(); }
}
数据库 tid int(11) No None AUTO_INCREMENT uid int(11) No None tuid int(11) No None balance int(11) No None type enum('personal', 'govt', 'business', 'tax') latin1_swedish_ci 没有日期 datetime