Doctrine_Query provides having() method for adding HAVING conditions to the DQL query. This method is identical in function to the Doctrine_Query::where() method.
<br\><br\>
If you call having() multiple times, the conditions are ANDed together; if you want to OR a condition, use orHaving(). <br\><br\>
You can quote the db identifiers (table and field names) with quoteIdentifier(). The delimiting style depends on which database driver is being used. NOTE: just because you CAN use delimited identifiers, it doesn't mean you SHOULD use them. In general, they end up causing way more problems than they solve. Anyway, it may be necessary when you have a reserved word as a field name (in this case, we suggest you to change it, if you can).
Some of the internal Doctrine methods generate queries. Enabling the "quote_identifier" attribute of Doctrine you can tell Doctrine to quote the identifiers in these generated queries. For all user supplied queries this option is irrelevant.
Portability is broken by using the following characters inside delimited identifiers:
<br\><br\>
<ul>
<li\>backtick (`) -- due to MySQL
<li\>double quote (") -- due to Oracle
<li\>brackets ([ or ]) -- due to Access
</ul>
Delimited identifiers are known to generally work correctly under the following drivers:
<br\>
<ul>
<li\>Mssql
<li\>Mysql
<li\>Oracle
<li\>Pgsql
<li\>Sqlite
<li\>Firebird
</ul>
When using the quoteIdentifiers option, all of the field identifiers will be automatically quoted in the resulting SQL statements:
<br\><br\>
<?php
renderCode("<?php
\$conn->setAttribute('quote_identifiers', true);
?>");
?>
<br\><br\>
will result in a SQL statement that all the field names are quoted with the backtick '`' operator (in MySQL).
<br\>
<divclass='sql'>SELECT * FROM `sometable` WHERE `id` = '123'</div>
<br\>
as opposed to:
<br\>
<divclass='sql'>SELECT * FROM sometable WHERE id='123'</div>
Each database management system (DBMS) has it's own behaviors. For example, some databases capitalize field names in their output, some lowercase them, while others leave them alone. These quirks make it difficult to port your scripts over to another server type. PEAR Doctrine:: strives to overcome these differences so your program can switch between DBMS's without any changes.
You control which portability modes are enabled by using the portability configuration option. Configuration options are set via factory() and setOption().
The portability modes are bitwised, so they can be combined using | and removed using ^. See the examples section below on how to do this.
<br\><br\>
Portability Mode Constants
<br\><br\>
<i>Doctrine::PORTABILITY_ALL (default)</i>
<br\><br\>
turn on all portability features. this is the default setting.
<br\><br\>
<i>Doctrine::PORTABILITY_DELETE_COUNT</i>
<br\><br\>
Force reporting the number of rows deleted. Some DBMS's don't count the number of rows deleted when performing simple DELETE FROM tablename queries. This mode tricks such DBMS's into telling the count by adding WHERE 1=1 to the end of DELETE queries.
<br\><br\>
<i>Doctrine::PORTABILITY_EMPTY_TO_NULL</i>
<br\><br\>
Convert empty strings values to null in data in and output. Needed because Oracle considers empty strings to be null, while most other DBMS's know the difference between empty and null.
<br\><br\>
<i>Doctrine::PORTABILITY_ERRORS</i>
<br\><br\>
Makes certain error messages in certain drivers compatible with those from other DBMS's
<br\><br\>
Table 33-1. Error Code Re-mappings
Driver Description Old Constant New Constant
mysql, mysqli unique and primary key constraints Doctrine::ERROR_ALREADY_EXISTS Doctrine::ERROR_CONSTRAINT
This removes any qualifiers from keys in associative fetches. some RDBMS , like for example SQLite, will be default use the fully qualified name for a column in assoc fetches if it is qualified in a query.
<br\><br\>
<i>Doctrine::PORTABILITY_FIX_CASE</i>
<br\><br\>
Convert names of tables and fields to lower or upper case in all methods. The case depends on the 'field_case' option that may be set to either CASE_LOWER (default) or CASE_UPPER
<br\><br\>
<i>Doctrine::PORTABILITY_NONE</i>
<br\><br\>
Turn off all portability features
<br\><br\>
<i>Doctrine::PORTABILITY_NUMROWS</i>
<br\><br\>
Enable hack that makes numRows() work in Oracle
<br\><br\>
<i>Doctrine::PORTABILITY_RTRIM</i>
<br\><br\>
Right trim the data output for all data fetches. This does not applied in drivers for RDBMS that automatically right trim values of fixed length character values, even if they do not right trim value of variable length character values.
<br\><br\>
Using setAttribute() to enable portability for lowercasing and trimming
// ALTER TABLE mytable ADD COLUMN name VARCHAR(255)
?>");
?>
<br\><br\>
Doctrine_Export::alterTable() takes two parameters:
<br\><br\>
string <i>$name</i>
<dd>name of the table that is intended to be changed. <br\>
array <i>$changes</i>
<dd>associative array that contains the details of each type of change that is intended to be performed.
The types of changes that are currently supported are defined as follows:
<ul>
<li\><i>name</i>
New name for the table.
<li\><i>add</i>
Associative array with the names of fields to be added as indexes of the array. The value of each entry of the array should be set to another associative array with the properties of the fields to be added. The properties of the fields should be the same as defined by the Doctrine parser.
<li\><i>remove</i>
Associative array with the names of fields to be removed as indexes of the array. Currently the values assigned to each entry are ignored. An empty array should be used for future compatibility.
<li\><i>rename</i>
Associative array with the names of fields to be renamed as indexes of the array. The value of each entry of the array should be set to another associative array with the entry named name with the new field name and the entry named Declaration that is expected to contain the portion of the field declaration already in DBMS specific SQL code as it is used in the CREATE TABLE statement.
<li\><i>change</i>
Associative array with the names of the fields to be changed as indexes of the array. Keep in mind that if it is intended to change either the name of a field and any other properties, the change array entries should have the new names of the fields as array indexes.
</ul>
The value of each entry of the array should be set to another associative array with the properties of the fields to that are meant to be changed as array entries. These entries should be assigned to the new values of the respective properties. The properties of the fields should be the same as defined by the Doctrine parser.