Basically,_getConditionSql(()
is a protected function of class Varien_Data_Collection_Db
.
So, without calling a resource collection class
you could not call this function.
In a interval view,this function is call Mysql PDO DB adapter (Varien_Db_Adapter_Pdo_Mysql)
class functionprepareSqlCondition()
function and that is a public function.
For your case,you will get relative result using Resource read/write adpater
and with help of prepareSqlCondition()
.
To read adapter:
Mage::getSingleton('core/resource')->getConnection('core_read');
To write adapter:
Mage::getSingleton('core/resource')->getConnection('core_write');
The expression may should look this:
$readAdapter- = Mage::getSingleton('core/resource')
->getConnection('core_write');
$expression = '(field1-field2)';
$inCond = $readAdapter->prepareSqlCondition($expression, $condition);
$select = $readAdapter->select()
->from($Table, array('*'))
->where($inCond);
$collection resource collection object:
If $collection is a resource collection object
then you can use below:
$readAdapter = Mage::getSingleton('core/resource')
->getConnection('core_write');
$expression = '(field1-field2)';
$inCond = $readAdapter->prepareSqlCondition($expression, $condition);
$collection->getSelect()->where($inCond);