根据不同的条件选择不同的值

时间:2015-12-16 10:30:49

标签: php mysql

如何在单个语句中根据mysql和PHP中的不同条件选择和求和不同的值。请仔细查看图片以理解概念。感谢

enter image description here

1 个答案:

答案 0 :(得分:0)

总策略是这样的:

public class ProcessHome {

   private static ProcessHome instance = new ProcessHome();

   //default Constructor
   private ProcessHome() {
   }

   public static ProcessHome getInstance() {
      return instance;
   }

   public IProcessObj getProcessObj() throws POException {
      return ProcessObj.getInstance(); //this is below
   }
}

public class ProcessObj implements IProcessObj {
   // instance
   private static IProcessObj instance;
   ...
   //constuctor
   private ProcessObj() throws POException {
      init();
   }

   static IProcessObj getInstance() throws POException {
      if (instance == null) {
            instance = new ProcessObj();
      }
      return instance;
   }


//jUnit test class


public class ProcessHomeTest {
    private IProcessObj iPO = ProcessHome.getInstance()
            .ProcessObj();

   @Test
   public void testIProcessObj() throws Exception {
         //use iPO heretest iPO
    assertEquals("some","some");
    }