[fw-general] Pls help with unwanted quotes in db-queries

2013-04-19 Thread GJ Bogaerts
Hello all,

I'm having some trouble removing quotes from certain parts of my db-queries.
For instance, this is part of a select()-statement:

$select-join(array('m' = 'media'), m.foreignKey = p.id and
m.belongsTo='product', array('mediaType', 'media' = $paths),
$select::JOIN_LEFT);

The on-part of this join produces: `m`.`foreignKey` = `p`.`id` and
`m`.`belongsTo` = `'product'` - the backticks around product are actually
invalid in pdo_mysql. How can I avoid them?

And on a related issue: In Zf1 you were able to provide a data-type with any
query-part, so you were able to actually use optimal data-types for your
database (i.e. an int was treated as int). Now even an int gets quoted,
which hinders performance on columns that contain the int-datatype. Is there
any way to influence this?

I've searched high and low in the documentation, but just couldn't find it.
Hope someone can help me!

GJ 



--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Pls-help-with-unwanted-quotes-in-db-queries-tp4659783.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com




Re: [fw-general] Pls help with unwanted quotes in db-queries

2013-04-19 Thread Ralph Schindler



$select-join(array('m' = 'media'), m.foreignKey = p.id and
m.belongsTo='product', array('mediaType', 'media' = $paths),
$select::JOIN_LEFT);

The on-part of this join produces: `m`.`foreignKey` = `p`.`id` and
`m`.`belongsTo` = `'product'` - the backticks around product are actually
invalid in pdo_mysql. How can I avoid them?


It looks like you want a complex ON part to your JOIN statement.

For anything non-trivial (meaning anything that requires expressions 
that might contain values or SQL expressions), you may want to use the 
Expression object to ensure exactly what you want.


Here is an example with an Expression as the ON part:

https://github.com/zendframework/zf2/blob/master/tests/ZendTest/Db/Sql/SelectTest.php#L952-L958

And here is an example of the ON part with predicates and predicate sets:

https://github.com/zendframework/zf2/blob/master/tests/ZendTest/Db/Sql/SelectTest.php#L952-L958



And on a related issue: In Zf1 you were able to provide a data-type with any
query-part, so you were able to actually use optimal data-types for your
database (i.e. an int was treated as int). Now even an int gets quoted,
which hinders performance on columns that contain the int-datatype. Is there


Can you find me some documentation on this assertion? And, which 
platform you're talking about? (I assume MySQL?)


-ralph

--
List: fw-general@lists.zend.com
Info: http://framework.zend.com/archives
Unsubscribe: fw-general-unsubscr...@lists.zend.com