Author: dr
Date: Fri Jan 18 09:57:30 2008
New Revision: 7171
Log:
- Implemented issue #10753: ezcDbQuery should implement __toString().
Modified:
trunk/Database/ChangeLog
trunk/Database/src/sqlabstraction/query.php
trunk/Database/tests/sqlabstraction/query_test.php
Modified: trunk/Database/ChangeLog
==============================================================================
--- trunk/Database/ChangeLog [iso-8859-1] (original)
+++ trunk/Database/ChangeLog [iso-8859-1] Fri Jan 18 09:57:30 2008
@@ -1,3 +1,9 @@
+1.4alpha1 - [RELEASEDATE]
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Implemented issue #10753: ezcDbQuery should implement __toString().
+
+
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] Fri Jan 18
09:57:30 2008
@@ -461,6 +461,28 @@
}
/**
+ * Return SQL string for query.
+ *
+ * Typecasting to (string) should be used to make __toString() to be called
+ * with PHP 5.1. This will not be needed in PHP 5.2 and higher when this
+ * object is used in a string context.
+ *
+ * Example:
+ * <code>
+ * $q->select('*')
+ * ->from( 'table1' )
+ * ->where ( $q->expr->eq( 'name', $q->bindValue( "Beeblebrox" ) ) );
+ * echo $q, "\n";
+ * </code>
+ *
+ * @return string
+ */
+ public function __toString()
+ {
+ return $this->getQuery();
+ }
+
+ /**
* Returns the query string for this query object.
*
* @throws ezcQueryInvalidException if it was not possible to build a
valid query.
Modified: trunk/Database/tests/sqlabstraction/query_test.php
==============================================================================
--- trunk/Database/tests/sqlabstraction/query_test.php [iso-8859-1] (original)
+++ trunk/Database/tests/sqlabstraction/query_test.php [iso-8859-1] Fri Jan 18
09:57:30 2008
@@ -190,5 +190,18 @@
$this->assertEquals( ':ezcValue2', $this->q->bindParam( $value ) );
$this->assertEquals( ':ezcValue3', $this->q->bindValue( $value ) );
}
+
+ public function testToString()
+ {
+ $q = ezcDbInstance::get()->createSelectQuery();
+ $reference = 'SELECT orders.Recipient FROM orders';
+
+ $q->setAliases( array( 'Order' => 'orders', 'Recipient' =>
'orders.company' ) );
+ $q->select( 'Order.Recipient' )
+ ->from( 'Order' );
+
+ $this->assertEquals( $reference, (string) $q );
+ $this->assertEquals( $q->getQuery(), (string) $q );
+ }
}
?>
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components