Author: dr
Date: Wed Feb 13 09:53:35 2008
New Revision: 7355
Log:
- Implemented issue #12540: subselect support for other query types besides
SELECT.
Modified:
trunk/Database/ChangeLog
trunk/Database/src/sqlabstraction/query.php
trunk/Database/src/sqlabstraction/query_select.php
trunk/Database/tests/sqlabstraction/query_subselect_test.php
Modified: trunk/Database/ChangeLog
==============================================================================
--- trunk/Database/ChangeLog [iso-8859-1] (original)
+++ trunk/Database/ChangeLog [iso-8859-1] Wed Feb 13 09:53:35 2008
@@ -2,6 +2,8 @@
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Implemented issue #10753: ezcDbQuery should implement __toString().
+- Implemented issue #12540: subselect support for other query types besides
+ SELECT.
1.3.4 - Monday 14 January 2008
Modified: trunk/Database/src/sqlabstraction/query.php
==============================================================================
--- trunk/Database/src/sqlabstraction/query.php [iso-8859-1] (original)
+++ trunk/Database/src/sqlabstraction/query.php [iso-8859-1] Wed Feb 13
09:53:35 2008
@@ -483,6 +483,20 @@
}
/**
+ * Returns the ezcQuerySubSelect query object.
+ *
+ * This method creates new ezcQuerySubSelect object
+ * that could be used for building correct
+ * subselect inside query.
+ *
+ * @return ezcQuerySubSelect
+ */
+ public function subSelect()
+ {
+ return new ezcQuerySubSelect( $this );
+ }
+
+ /**
* Returns the query string for this query object.
*
* @throws ezcQueryInvalidException if it was not possible to build a
valid query.
Modified: trunk/Database/src/sqlabstraction/query_select.php
==============================================================================
--- trunk/Database/src/sqlabstraction/query_select.php [iso-8859-1] (original)
+++ trunk/Database/src/sqlabstraction/query_select.php [iso-8859-1] Wed Feb 13
09:53:35 2008
@@ -895,20 +895,6 @@
return $query;
}
- /**
- * Returns the ezcQuerySubSelect query object.
- *
- * This method creates new ezcQuerySubSelect object
- * that could be used for building correct
- * subselect inside query.
- *
- * @return ezcQuerySubSelect
- */
- public function subSelect()
- {
- return new ezcQuerySubSelect( $this );
- }
-
}
?>
Modified: trunk/Database/tests/sqlabstraction/query_subselect_test.php
==============================================================================
--- trunk/Database/tests/sqlabstraction/query_subselect_test.php [iso-8859-1]
(original)
+++ trunk/Database/tests/sqlabstraction/query_subselect_test.php [iso-8859-1]
Wed Feb 13 09:53:35 2008
@@ -177,6 +177,43 @@
$this->assertEquals( "SELECT somecol FROM quiz WHERE question IN ( (
SELECT id FROM question WHERE quiz = :ezcValue1 ) )", $q->getQuery() );
}
+ public function testSubselectWithUpdate()
+ {
+ $db = ezcDbInstance::get();
+ $q = $db->createUpdateQuery();
+ $q->update( 'quiz' )->set( 'somecol', $q->bindValue( 'test' ) );
+
+ $qQuestions = $q->subSelect();
+ $qQuestions->select( 'id' )->from( 'question' )->where(
+ $qQuestions->expr->eq( 'quiz', $qQuestions->bindValue( 1 ) )
+ );
+
+ $q->where(
+ $q->expr->in( 'question', $qQuestions )
+ );
+
+ $this->assertEquals( "UPDATE quiz SET somecol = :ezcValue1 WHERE
question IN ( ( SELECT id FROM question WHERE quiz = :ezcValue2 ) )",
$q->getQuery() );
+ }
+
+
+ public function testSubselectWithDelete()
+ {
+ $db = ezcDbInstance::get();
+ $q = $db->createDeleteQuery();
+ $q->deleteFrom( 'quiz' );
+
+ $qQuestions = $q->subSelect();
+ $qQuestions->select( 'id' )->from( 'question' )->where(
+ $qQuestions->expr->eq( 'quiz', $qQuestions->bindValue( 1 ) )
+ );
+
+ $q->where(
+ $q->expr->in( 'question', $qQuestions )
+ );
+
+ $this->assertEquals( "DELETE FROM quiz WHERE question IN ( ( SELECT id
FROM question WHERE quiz = :ezcValue1 ) )", $q->getQuery() );
+ }
+
public static function suite()
{
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components