MINOR Fixed SQL quoting (requires 2.4)

MINOR Added ingo at ss dot org as a maintainer
This commit is contained in:
Ingo Schommer 2010-03-22 10:49:04 +00:00
parent f508442eb5
commit 89513c6da6
5 changed files with 19 additions and 16 deletions

5
README
View File

@ -12,9 +12,12 @@ Maintainer Contact
Sean Harvey (Nickname: sharvey, halkyon)
<sean (at) silverstripe (dot) com>
Ingo Schommer (Nickname: chillu)
<ingo (at) silverstripe (dot) com>
Requirements
-----------------------------------------------
SilverStripe 2.2.2 or higher is required.
SilverStripe 2.4 or higher is required.
Documentation
-----------------------------------------------

View File

@ -265,7 +265,7 @@ abstract class MultiForm extends Form {
function getSavedSteps() {
return DataObject::get(
'MultiFormStep',
sprintf("SessionID = '%s'",
sprintf("\"SessionID\" = '%s'",
$this->session->ID
)
);
@ -442,7 +442,7 @@ abstract class MultiForm extends Form {
}
// Get the previous step of the class instance returned from $currentStep->getPreviousStep()
$prevStep = DataObject::get_one($prevStepClass, "SessionID = {$this->session->ID}");
$prevStep = DataObject::get_one($prevStepClass, "\"SessionID\" = {$this->session->ID}");
// Set the current step as the previous step
$this->setCurrentStep($prevStep);
@ -501,7 +501,7 @@ abstract class MultiForm extends Form {
public function getAllStepsLinear() {
$stepsFound = new DataObjectSet();
$firstStep = DataObject::get_one($this->stat('start_step'), "SessionID = {$this->session->ID}");
$firstStep = DataObject::get_one($this->stat('start_step'), "\"SessionID\" = {$this->session->ID}");
$templateData = array(
'ID' => $firstStep->ID,
'ClassName' => $firstStep->class,
@ -571,7 +571,7 @@ abstract class MultiForm extends Form {
* @return int
*/
public function getCompletedStepCount() {
$steps = DataObject::get('MultiFormStep', "SessionID = {$this->session->ID} && Data IS NOT NULL");
$steps = DataObject::get('MultiFormStep', "\"SessionID\" = {$this->session->ID} && \"Data\" IS NOT NULL");
return $steps ? $steps->Count() : 0;
}

View File

@ -35,7 +35,7 @@ class MultiFormObjectDecorator extends DataObjectDecorator {
&& strpos($query->where[0], "ID = ") !== 0
&& !$this->wantsTemporary($query)
) {
$query->where[] = "`{$query->from[0]}`.`MultiFormIsTemporary` = 0";
$query->where[] = "\"{$query->from[0]}\".\"MultiFormIsTemporary\" = 0";
}
}
@ -49,7 +49,7 @@ class MultiFormObjectDecorator extends DataObjectDecorator {
*/
protected function wantsTemporary($query) {
foreach($query->where as $whereClause) {
if($whereClause == "`{$query->from[0]}`.`MultiFormIsTemporary` = 1") return true;
if($whereClause == "\"{$query->from[0]}\".\"MultiFormIsTemporary\" = 1") return true;
}
return false;
}

View File

@ -45,7 +45,7 @@ class MultiFormPurgeTask extends DailyTask {
protected function getExpiredSessions() {
return DataObject::get(
'MultiFormSession',
"DATEDIFF(NOW(), `MultiFormSession`.`Created`) > " . self::$session_expiry_days
"DATEDIFF(NOW(), \"MultiFormSession\".\"Created\") > " . self::$session_expiry_days
);
}

View File

@ -233,9 +233,9 @@ class MultiFormStep extends DataObject {
if($this->SessionID && is_numeric($this->SessionID)) {
$nextSteps = $this->stat('next_steps');
if(is_string($nextSteps)) {
return DataObject::get_one($nextSteps, "SessionID = {$this->SessionID}");
return DataObject::get_one($nextSteps, "\"SessionID\" = {$this->SessionID}");
} elseif(is_array($nextSteps)) {
return DataObject::get_one($nextSteps[0], "SessionID = {$this->SessionID}");
return DataObject::get_one($nextSteps[0], "\"SessionID\" = {$this->SessionID}");
} else {
return false;
}
@ -260,7 +260,7 @@ class MultiFormStep extends DataObject {
* @return String Classname of a {@link MultiFormStep} subclass
*/
public function getPreviousStep() {
$steps = DataObject::get('MultiFormStep', "SessionID = {$this->SessionID}", 'LastEdited DESC');
$steps = DataObject::get('MultiFormStep', "\"SessionID\" = {$this->SessionID}", '"LastEdited" DESC');
if($steps) {
foreach($steps as $step) {
if($step->getNextStep()) {
@ -281,7 +281,7 @@ class MultiFormStep extends DataObject {
*/
public function getPreviousStepFromDatabase() {
if($prevStepClass = $this->getPreviousStep()) {
return DataObject::get_one($prevStepClass, "SessionID = {$this->SessionID}");
return DataObject::get_one($prevStepClass, "\"SessionID\" = {$this->SessionID}");
}
}