function up() { $sql = "CREATE TABLE status\n\t\t\t\t(\n\t\t\t\t id integer primary key,\n\t\t\t\t\tname text,\n\t\t\t\t\tlist_order integer\n\t\t\t\t)"; SqlAlterSchema($sql); $sql = "INSERT INTO status (id, name, list_order) VALUES (:id, :name, :listOrder)"; SqlUpdateRow($sql, array('id' => 1, 'name' => 'new', 'listOrder' => 1)); SqlUpdateRow($sql, array('id' => 4, 'name' => 'resolved', 'listOrder' => 4)); $sql = "ALTER TABLE request ADD COLUMN status_id INTEGER REFERENCES status NOT NULL DEFAULT 1"; SqlAlterSchema($sql); }
public static function appendBindings($newBindings) { $formId = getPostInt('_zinc_form_id'); $sessionId = session_id(); // IMPORTANT SECURITY NOTE: // even though session.id is going to be a unique identifier we still need to check to make sure that it // has the correct session_id to prevent spoofing $fieldString = SqlFetchCell("select fields from session_form where session_id = :sessionId and id = :formId", array('sessionId' => $sessionId, 'formId' => $formId)); if (!$fieldString) { trigger_error("session_form row {$formId} not found. Possible attempt to spoof session data."); } $parts = array(); foreach ($newBindings as $thisBinding) { if (is_array($thisBinding)) { $bindingObject = new FormBinding($thisBinding['object'], $thisBinding['field']); } else { $bindingObject = $thisBinding; } $parts[] = $bindingObject->getString(); } $appendString = implode(',', $parts); SqlUpdateRow("update session_form set fields = :newFieldString where session_id = :sessionId and id = :formId", array('sessionId' => $sessionId, 'formId' => $formId, 'newFieldString' => $fieldString . ',' . $appendString)); }
function stop() { SqlUpdateRow("update entry set endtime = now() where id = :id", array('id' => $this->id)); }
/** * Executes an update statement on the database (identical to SqlUpdateRow) * * Unlike SqlQuery, this method does not return a DbResultSet objects * * @param string $sql SQL query with parameters in the format ":variablename" or ":variablename:datatype" * @param array($key=>$value) $params ($key => value) array of parameters to substitute into the SQL query. If you are not passing parameters in, params should be an empty array() * @return number Number of affected rows (not all database engines support this) */ function SqlModifyRow($sql, $params) { // Is this supposed to work different from SqlUpdateRow? //return DbModule::getDefaultConnection()->modifyRow($sql, $params); return SqlUpdateRow($sql, $params); }