/** * Ensures that a blank base record exists with the basic fixed fields for this dataobject * * Does nothing if an ID is already assigned for this record * * @param string $baseTable Base table * @param string $now Timestamp to use for the current time */ protected function writeBaseRecord($baseTable, $now) { // Generate new ID if not specified if ($this->isInDB()) { return; } // Perform an insert on the base table $insert = new SQLInsert('"' . $baseTable . '"'); $insert->assign('"Created"', $now)->execute(); $this->changed['ID'] = self::CHANGE_VALUE; $this->record['ID'] = DB::get_generated_id($baseTable); }
/** * Writes the fixture into the database directly using a database manipulation. * Does not use blueprints. Only supports tables with a primary key. * * @param String $table Existing database table name * @param String $identifier Unique identifier for this fixture type * @param Array $data Map of properties * @return Int Database identifier */ public function createRaw($table, $identifier, $data) { $fields = array(); foreach ($data as $fieldName => $fieldVal) { $fields["\"{$fieldName}\""] = $this->parseValue($fieldVal); } $insert = new SQLInsert("\"{$table}\"", $fields); $insert->execute(); $id = DB::get_generated_id($table); $this->fixtures[$table][$identifier] = $id; return $id; }