public function execute($dbh) { if ($this->stmt != '') { SDO_DAS_Relational_DatabaseHelper::executeStatementTestForCollision($dbh, $this->stmt, $this->value_list); } return $this->spawned_actions; }
public function execute($dbh) { $pk_from = SDO_DAS_Relational_DataObjectHelper::getPrimaryKeyFromDataObject($this->object_model, $this->from_who); $pk_to = SDO_DAS_Relational_DataObjectHelper::getPrimaryKeyFromDataObject($this->object_model, $this->who_to); $type_name = SDO_DAS_Relational_DataObjectHelper::getApplicationType($this->from_who); $name_of_the_pk_column = $this->object_model->getPropertyRepresentingPrimaryKeyFromType($type_name); $stmt = "UPDATE {$type_name} SET {$this->property_name} = ? WHERE {$name_of_the_pk_column} = ?"; $value_list = array($pk_to, $pk_from); SDO_DAS_Relational_DatabaseHelper::executeStatementTestForCollision($dbh, $stmt, $value_list); }
public static function executeStatementTestForCollision($dbh, $stmt, $value_list) { // execute the SQL statement through PDO $pdo_stmt = $dbh->prepare($stmt); $rows_affected = SDO_DAS_Relational_DatabaseHelper::executeStatementTestForError($dbh, $pdo_stmt, $value_list, $stmt); // Test if the SQL execute resulted in any change rows if ($rows_affected == 0) { $msg = "\nSDO/DAS/Relational.php::applyChanges resulted in no rows being affect when executing {$stmt}"; $msg .= "\nThis may happen if the data that was retrieved and updated has been changed by another processs in the database in the meantime."; $dbh->rollback(); $msg .= "\nAll changes have been rolled back."; throw new SDO_DAS_Relational_Exception($msg); } }
public function execute($dbh) { $this->addFKToParentToSettings(); $this->stmt = $this->toSQL(); $this->buildValueList(); SDO_DAS_Relational_DatabaseHelper::executeStatementTestForCollision($dbh, $this->stmt, $this->value_list); $this->storeThisObjectsPrimaryKey($dbh); return $this->spawned_actions; }
/** * Given an SQL query in the form of a prepared PDO statement and a value list, execute it, * normalise the result set into a data graph and return it. */ public function executePreparedQuery($dbh, $pdo_stmt, $value_list, $column_specifier = null) { $this->ensureValueListIsNullOrAnArray($value_list); $this->ensureColumnSpecifierIsNullOrAnArrayContainingOnlyValidTableAndColumnNames($column_specifier); $dbh->beginTransaction(); $rows_affected = SDO_DAS_Relational_DatabaseHelper::executeStatementTestForError($dbh, $pdo_stmt, $value_list, null); $root = $this->normaliseResultSet($pdo_stmt, $column_specifier); $dbh->commit(); return $root; }