如何将嵌套的sql查询转换为zend 1.12格式

时间:2015-08-24 11:00:42

标签: php mysql zend-framework zend-db zend-db-table

我的查询:

select distinct ml.send_to from message_log as ml where NOT exists
(select mobile_no from user_details WHERE user_details.mobile_no = ml.send_to);

2 个答案:

答案 0 :(得分:1)

$select1 = $db->select()->from('user_details',array('mobile_no'))
                  ->where('user_details.mobile_no = ml.send_to');

$select2 = $db->select()->distinct()
               ->from(array('ml'=>'message_log'), array('ml.send_to')))
               ->where('NOT EXISTS ?', $select1);

这将以最简单的方式完成。

答案 1 :(得分:0)

您可以在zend中使用客户查询

sparkuser@spark:~$ sbt assembly/ Picked up JAVA_TOOL_OPTIONS:
-javaagent:/usr/share/java/jayatanaag.jar  Getting org.scala-sbt sbt 0.13.9 ...

:: problems summary :: :::: WARNINGS        module not found: org.scala-sbt#sbt;0.13.9

    ==== local: tried

      /home/sparkuser/.ivy2/local/org.scala-sbt/sbt/0.13.9/ivys/ivy.xml

      -- artifact org.scala-sbt#sbt;0.13.9!sbt.jar:

      /home/sparkuser/.ivy2/local/org.scala-sbt/sbt/0.13.9/jars/sbt.jar

    ==== jcenter: tried

      https://jcenter.bintray.com/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.pom

      -- artifact org.scala-sbt#sbt;0.13.9!sbt.jar:

      https://jcenter.bintray.com/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.jar

    ==== typesafe-ivy-releases: tried

      https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.9/ivys/ivy.xml

    ==== Maven Central: tried

      https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.pom

      -- artifact org.scala-sbt#sbt;0.13.9!sbt.jar:

      https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.jar

        ::::::::::::::::::::::::::::::::::::::::::::::

        ::          UNRESOLVED DEPENDENCIES         ::

        ::::::::::::::::::::::::::::::::::::::::::::::

        :: org.scala-sbt#sbt;0.13.9: not found

        ::::::::::::::::::::::::::::::::::::::::::::::


:::: ERRORS     Server access Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty url=https://jcenter.bintray.com/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.pom

    Server access Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty url=https://jcenter.bintray.com/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.jar

    Server access Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty url=https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.9/ivys/ivy.xml

    Server access Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty url=https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.pom

    Server access Error: java.lang.RuntimeException: Unexpected error: java.security.InvalidAlgorithmParameterException: the trustAnchors parameter must be non-empty url=https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.9/sbt-0.13.9.jar

这真的会对你有所帮助

http://framework.zend.com/manual/1.12/en/zend.db.statement.html