public function testUpdateSucceedsWithExprValue() { $this->db->update('dewdrop_test_fruits', array('level_of_deliciousness' => new Expr(100)), 'dewdrop_test_fruit_id = 1'); $this->assertEquals(100, $this->db->fetchOne('SELECT level_of_deliciousness FROM dewdrop_test_fruits WHERE dewdrop_test_fruit_id = 1')); }
/** * When Dewdrop was WP-only, the primary dbdeploy changeset was called "plugin". * We now support several environments and calling projects "plugins" doesn't * make sense in some cases. To reflect this, the EnvInterface->getProjectNoun() * method was added. Because existing projects had "plugin" in the dbdeploy_changelog * already, this method is in place to update any of those records on older * projects. */ public function maintainBackwardCompatibilityOnPrimaryChangeset() { $primaryChangesetName = Env::getInstance()->getProjectNoun(); if ('plugin' !== $primaryChangesetName) { $this->dbAdapter->update($this->tableName, ['delta_set' => $primaryChangesetName], "delta_set = 'plugin'"); } }
/** * Update an existing row. * * Data should be supplied as key value pairs, with the keys representing * the column names. The where clause should be an already assembled * and quoted string. It should not be prefixed with the "WHERE" keyword. * * @param array $data * @param string $where * @return integer The number of rows affected. */ public function update(array $data, $where) { $result = 0; $updateData = $this->augmentUpdatedDataArrayWithWhenAndByWhom($this->filterDataArrayForPhysicalColumns($data)); // Only perform primary update statement if a physical column is being updated if (count($updateData)) { $result = $this->db->update($this->tableName, $updateData, $where); } $this->saveManyToManyRelationships($data)->saveEav($data); return $result; }