public function getNextValue($sequence = '', $tableGenerator = 'manager_sequence') { $sql = new \database\MSQL("value", $tableGenerator, "(sequence='" . $sequence . "')"); $sql->setDb($this->db); $result = $this->db->query($sql->select()); $value = $result[0][0]; $sql = new \database\MSQL("value", $tableGenerator, "(sequence='" . $sequence . "')"); $sql->setDb($this->db); $result = $this->db->query($sql->update(':value + 1')); return $value; }
public function getSqlStatement() { $statement = new \database\MSQL(); $statement->setDb($this->getClassMap()->getDb()); $statement->setTables($this->classMap->getUpdateSql()); if (count($this->columnAttributes)) { $i = 0; $columns = ''; foreach ($this->columnAttributes as $column) { if ($i++) { $columns .= ','; } $columns .= $this->getOperand($column)->getSql(); } $statement->setColumns($columns); } // Add 'WHERE' clause to update statement if (($whereCondition = $this->whereCondition->getSql()) != '') { $statement->setWhere($whereCondition); } return $statement; }
public function getUpdateStatementId($object, $id, $value = NULL) { // $id = array com PK dos objetos associados $statement = new \database\MSQL(); $statement->setDb($this->fromClassMap->getDb()); $statement->setTables($this->toClassMap->getTableName()); $a = new OperandArray($id); $statement->setColumns($this->toAttributeMap->getName()); $whereCondition = $this->toClassMap->getKeyAttributeName() . ' IN ' . $a->getSql(); $statement->setWhere($whereCondition); //$statement->setParameters($object->getOIDValue()); $statement->setParameters($value); return $statement->update(); }