*/
public function withUid($uid) {
$sourceSelectorName = $this->getSource()->getSelectorName();
- $this->operands['uid'] = $uid;
+ $uniqueVariableName = $this->getUniqueVariableName('uid');
+ $this->operands[$uniqueVariableName] = $uid;
return $this->QOMFactory->comparison(
$this->QOMFactory->propertyValue('uid', $sourceSelectorName),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO,
- $this->QOMFactory->bindVariable('uid')
+ $this->QOMFactory->bindVariable($uniqueVariableName)
);
}
*/
public function equals($propertyName, $operand, $caseSensitive = TRUE) {
$source = $this->getSource();
+ $uniqueVariableName = uniqid($propertyName);
if ($source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) {
$sourceSelectorName = $this->getSource()->getSelectorName();
}
$comparison = $this->QOMFactory->comparison(
$this->QOMFactory->propertyValue($propertyName, $sourceSelectorName),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO,
- $this->QOMFactory->bindVariable($propertyName)
+ $this->QOMFactory->bindVariable($uniqueVariableName)
);
- $this->operands[$propertyName] = $operand;
+ $this->operands[uniqid($propertyName)] = $operand;
} else {
if ($caseSensitive) {
$comparison = $this->QOMFactory->comparison(
$this->QOMFactory->propertyValue($propertyName, $sourceSelectorName),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO,
- $this->QOMFactory->bindVariable($propertyName)
+ $this->QOMFactory->bindVariable($uniqueVariableName)
);
} else {
$comparison = $this->QOMFactory->comparison(
$this->QOMFactory->propertyValue($propertyName, $sourceSelectorName)
),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_EQUAL_TO,
- $this->QOMFactory->bindVariable($propertyName)
+ $this->QOMFactory->bindVariable($uniqueVariableName)
);
}
if ($caseSensitive) {
- $this->operands[$propertyName] = $operand;
+ $this->operands[$uniqueVariableName] = $operand;
} else {
- $this->operands[$propertyName] = strtolower($operand);
+ $this->operands[$uniqueVariableName] = strtolower($operand);
}
}
*/
public function like($propertyName, $operand) {
$source = $this->getSource();
+ $uniqueVariableName = uniqid($propertyName);
if ($source instanceof Tx_Extbase_Persistence_QOM_SelectorInterface) {
$sourceSelectorName = $this->getSource()->getSelectorName();
}
// TODO $sourceSelectorName might not be initialized
- $this->operands[$propertyName] = $operand;
+ $this->operands[$uniqueVariableName] = $operand;
return $this->QOMFactory->comparison(
$this->QOMFactory->propertyValue($propertyName, $sourceSelectorName),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LIKE,
- $this->QOMFactory->bindVariable($propertyName)
+ $this->QOMFactory->bindVariable($uniqueVariableName)
);
}
*/
public function lessThan($propertyName, $operand) {
$sourceSelectorName = $this->getSource()->getSelectorName();
- $this->operands[$propertyName] = $operand;
+ $uniqueVariableName = uniqid($propertyName);
+ $this->operands[$uniqueVariableName] = $operand;
return $this->QOMFactory->comparison(
$this->QOMFactory->propertyValue($propertyName, $sourceSelectorName),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LESS_THAN,
- $this->QOMFactory->bindVariable($propertyName)
+ $this->QOMFactory->bindVariable($uniqueVariableName)
);
}
*/
public function lessThanOrEqual($propertyName, $operand) {
$sourceSelectorName = $this->getSource()->getSelectorName();
- $this->operands[$propertyName] = $operand;
+ $uniqueVariableName = uniqid($propertyName);
+ $this->operands[$uniqueVariableName] = $operand;
return $this->QOMFactory->comparison(
$this->QOMFactory->propertyValue($propertyName, $sourceSelectorName),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_LESS_THAN_OR_EQUAL_TO,
- $this->QOMFactory->bindVariable($propertyName)
+ $this->QOMFactory->bindVariable($uniqueVariableName)
);
}
*/
public function greaterThan($propertyName, $operand) {
$sourceSelectorName = $this->getSource()->getSelectorName();
- $this->operands[$propertyName] = $operand;
+ $uniqueVariableName = uniqid($propertyName);
+ $this->operands[$uniqueVariableName] = $operand;
return $this->QOMFactory->comparison(
$this->QOMFactory->propertyValue($propertyName, $sourceSelectorName),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_GREATER_THAN,
- $this->QOMFactory->bindVariable($propertyName)
+ $this->QOMFactory->bindVariable($uniqueVariableName)
);
}
*/
public function greaterThanOrEqual($propertyName, $operand) {
$sourceSelectorName = $this->getSource()->getSelectorName();
- $this->operands[$propertyName] = $operand;
+ $uniqueVariableName = uniqid($propertyName);
+ $this->operands[$uniqueVariableName] = $operand;
return $this->QOMFactory->comparison(
$this->QOMFactory->propertyValue($propertyName, $sourceSelectorName),
Tx_Extbase_Persistence_QOM_QueryObjectModelConstantsInterface::JCR_OPERATOR_GREATER_THAN_OR_EQUAL_TO,
- $this->QOMFactory->bindVariable($propertyName)
+ $this->QOMFactory->bindVariable($uniqueVariableName)
);
}
+ protected function getUniqueVariableName($propertyName) {
+ return uniqid($propertyName);
+ }
+
}
?>
* @var t3lib_pageSelect
*/
protected $pageSelectObject;
-
+
+ /**
+ * TRUE if the framework should add the "enable fields" (e.g. checking for hidden or deleted records)
+ *
+ * @var boolean
+ */
+ protected $useEnableFields = TRUE;
+
/**
* TRUE if automatic cache clearing in TCEMAIN should be done on insert/update/delete, FALSE otherwise.
*
/**
* Constructs this Storage Backend instance
+ *
+ * @param t3lib_db $databaseHandle The database handle
*/
- public function __construct() {
- $this->databaseHandle = $GLOBALS['TYPO3_DB'];
+ public function __construct($databaseHandle) {
+ $this->databaseHandle = $databaseHandle;
}
/**
*/
public function getRows(Tx_Extbase_Persistence_QOM_QueryObjectModelInterface $query) {
$sql = array();
+ $sql['tables'] = array();
+ $sql['fields'] = array();
+ $sql['where'] = array();
+ $sql['enableFields'] = array();
+ $sql['orderings'] = array();
$parameters = array();
$tuples = array();
$this->parseConstraint($query->getConstraint(), $sql, $parameters, $query->getBoundVariableValues());
if (!empty($sql['where'])) {
- $sqlString .= ' WHERE ' . implode('', $sql['where']) . ' AND ' . implode(' AND ', $sql['enableFields']);
- } else {
+ $sqlString .= ' WHERE ' . implode('', $sql['where']);
+ if (!empty($sql['enableFields'])) {
+ $sqlString .= ' AND ' . implode(' AND ', $sql['enableFields']);
+ }
+ } elseif (!empty($sql['enableFields'])) {
$sqlString .= ' WHERE ' . implode(' AND ', $sql['enableFields']);
}
$sql['fields'][] = $selectorName . '.*';
$sql['tables'][] = $selectorName;
// TODO Should we make the usage of enableFields configurable? And how? Because the Query object and even the QOM should be abstracted from the storage backend.
- $this->addEnableFieldsStatement($selectorName, $sql);
+ if ($this->useEnableFields === TRUE) {
+ $this->addEnableFieldsStatement($selectorName, $sql);
+ }
} elseif ($source instanceof Tx_Extbase_Persistence_QOM_JoinInterface) {
$this->parseJoin($source, $sql, $parameters);
}