Save an entry in the database
506672
function (soajs, combo, cb) {
        soajs.mongoDb.save(combo.collection, combo.record, cb);
    }
835281
protected void addEntry (E entry)
    {
        if (_entryFilter == null || _entryFilter.apply(entry)) {
            int index = _keys.insertSorted(getKey(entry));
            _table.insertDatum(entry, index);
        }
    }
718103
protected function __save()
    {
        $this->parseDate();
        foreach($this->records as $record)
        {
            FileUtil::writeFile($this->getFileName(), $this->getLogString($record) . PHP_EOL, FILE_APPEND);
        }
    }
40604
public void save(DbSession dbSession, String key, String value) {
    checkKey(key);
    checkArgument(value != null && !value.isEmpty(), "value can't be null nor empty");

    InternalPropertiesMapper mapper = getMapper(dbSession);
    mapper.deleteByKey(key);
    long now = system2.now();
    if (mustsBeStoredInClob(value)) {
      mapper.insertAsClob(key, value, now);
    } else {
      mapper.insertAsText(key, value, now);
    }
  }
710592
public void doOpen() throws DBException
    {
        super.doOpen();
        try   {
            m_pTable.open(this);
        } catch (DBException ex)    {
            throw DatabaseException.toDatabaseException(ex);
        }
    }
88376
public function save() {

		if (empty(static::$table))
			$table = strtolower(substr(static::table(), strpos(static::table(), '\\')+1));
		else
			$table = static::$table;

		if (isset($this->_data[$table]) && count($this->_data[$table]) <= 0 ) {
			$post = $_POST;
			while(list($field, $value) = each($post)) {
				// Next if is Primary Keys
				// if (!empty($this->_id) && array_key_exists($field, $this->_id))
					// continue;
				
				$this->_data[$table][$field] = addslashes($value);
				$this->$field = $value;
			}
		}

		if ($table != '') {
			// Untuk menambah record
			if ($this->add == TRUE) {
				$before = $this->before();
				if (is_array($before) && count($before) > 1) {
					if (isset($before['insert'])) {
						$insert = $before['insert'];
						while(list($field, $value) = each($insert))
							$this->_data[$table][$field] = $value;
					}
				}
				$ret = self::$db->$table->insert($this->_data[$table]);
				$after = $this->after();
				if (is_array($after) && count($after) > 1) {
					if (isset($after['insert']) && is_callable($after['insert'])) {
						$insert = $after['insert'];
						$insert($this->_data[$table]);
					}
				}
			}
			// Untuk mengupdate record
			else {
				$before = $this->before();
				if (is_array($before) && count($before) > 1) {
					if (isset($before['update'])) {
						$update = $before['update'];
						while(list($field, $value) = each($update))
							$this->_data[$table][$field] = $value;
					}
				}
				$ret = self::$db->$table->update($this->_id, $this->_data[$table]);
				$after = $this->after();
				if (is_array($after) && count($after) > 1) {
					if (isset($after['update']) && is_callable($after['update'])) {
						$update = $after['update'];
						$update(array('pk'=>$this->_id, 'data'=>$this->_data[$table]));
					}
				}
			}
			
			$this->_data[$table] = array();
		}

		
		return $ret;
	}
431980
def save(self):
        
        try:
            if self.exists() is False:
                self.db.session.add(self)
            # self.db.session.merge(self)
            self.db.session.commit()
        except (Exception, BaseException) as error:
            if current_app.config['DEBUG']:
                raise error
            return None
1194309
def _saveDB(self):
        
        # We're a "fresh" copy now
        self._updated = time.time()
        if self._new:
            operation = 'INSERT'
            if not self._validID():
                self._setID(self._nextSequence())
            # Note that we assign this ID to our self
            # BEFORE possibly saving any of our attribute
            # objects that might be new as well. This means
            # that they might have references to us, as long
            # as the database does not require our existence
            # yet.
            #
            # Since mysql does not have Sequences, this will
            # not work as smoothly there. See class
            # MysqlForgetter below.
        else:
            operation = 'UPDATE'
        (sql, fields) = self._prepareSQL(operation)
        values = []
        for field in fields:
            value = getattr(self, field)
            # First some dirty datatype hacks
            if DateTime and type(value) == DateTime.DateTimeType:
                # stupid psycopg does not support it's own return type..
                # lovely..
                value = str(value)
            if DateTime and type(value) == DateTime.DateTimeDeltaType:
                # Format delta as days, hours, minutes seconds
                # NOTE: includes value.second directly to get the
                # whole floating number
                value = value.strftime("%d %H:%M:") + str(value.second)
            if value is True or value is False:
                # We must store booleans as 't' and 'f' ...
                value = value and 't' or 'f'
            if isinstance(value, Forgetter):
                # It's another object, we store only the ID
                if value._new:
                    # It's a new object too, it must be saved!
                    value.save()
                try:
                    (value,) = value._getID()
                except:
                    raise "Unsupported: Can't reference multiple-primary-key: %s" % value
            values.append(value)
        cursor = self.cursor()
        cursor.execute(sql, values)
        # cursor.commit()
        cursor.close()
        self._new = False
        self._changed = None
113410
async def save(self, db):
        
        kwargs = {}
        for col in self._auto_columns:
            if not self.has_real_data(col.name):
                kwargs[col.name] = await col.auto_generate(db, self)
        self.__dict__.update(kwargs)

        # we have to delete the old index key
        stale_object = await self.__class__.load(db, identifier=self.identifier())
        d = {
            k: (v.strftime(DATETIME_FORMAT) if isinstance(v, datetime) else v)
            for k, v in self.__dict__.items()
        }
        success = await db.hmset_dict(self.redis_key(), d)
        await self.save_index(db, stale_object=stale_object)
        return success
884536
def save(self, directory=None):
        
        from subprocess import call

        # If user did not supply a new directory, use the one loaded (default: tabledata)
        if isinstance(directory, type(None)):
            directory = self.directory

        # Create the .sql file is it doesn't exist, i.e. if the Database class called a .db file initially
        if not os.path.isfile(self.sqlpath):
            self.sqlpath = self.dbpath.replace('.db', '.sql')
            os.system('touch {}'.format(self.sqlpath))

        # # Write the data to the .sql file
        # with open(self.sqlpath, 'w') as f:
        #     for line in self.conn.iterdump():
        #         f.write('%s\n' % line)

        # Alternatively...
        # Write the schema
        os.system("echo '.output {}\n.schema' | sqlite3 {}".format(self.sqlpath, self.dbpath))

        # Write the table files to the tabledata directory
        os.system("mkdir -p {}".format(directory))
        tables = self.query("select tbl_name from sqlite_master where type='table'")['tbl_name']
        tablepaths = [self.sqlpath]
        for table in tables:
            print('Generating {}...'.format(table))
            tablepath = '{0}/{1}.sql'.format(directory, table)
            tablepaths.append(tablepath)
            with open(tablepath, 'w') as f:
                for line in self.conn.iterdump():
                    line = line.strip()
                    if line.startswith('INSERT INTO "{}"'.format(table)):
                        if sys.version_info.major == 2:
                            f.write(u'{}\n'.format(line).encode('utf-8'))
                        else:
                            f.write(u'{}\n'.format(line))

        print("Tables saved to directory {}/".format(directory))
        print("""=======================================================================================
You can now run git to commit and push these changes, if needed.
For example, if on the master branch you can do the following:
  git add {0} {1}/*.sql
  git commit -m "COMMIT MESSAGE HERE"
  git push origin master
You can then issue a pull request on GitHub to have these changes reviewed and accepted
======================================================================================="""
              .format(self.sqlpath, directory))
337213
public function save()
	{
		if (empty($this->dirty))
		{
			return;	// Nothing to do
		}

		// Now insert or update depending on $this->primary_key.
		if (isset($this->record[$this->primary_key]))
		{
			// Update this record
			$new_record = $this->update($this->record);
		}
		else
		{
			// Create this record
			$new_record = $this->insert($this->record);
		}

		// Replace the record
		$this->hydrate($new_record);
	}
645207
public function save()
    {
        if ($this->_isSaved) {
            $this->update($this->id);
        } else {
            $this->id = $this->insert();
            $this->_isSaved = true;
        }
    }
999990
public function save()
	{
		$this->db->begin();
		foreach($this->data as $item)
		{
			$this->db->insert($this->tableName,$item);
		}
		$this->db->commit();
		return true;
	}
600044
def insert_entry(self, entry, taxids):
        
        entry_dict = entry.attrib
        entry_dict['created'] = datetime.strptime(entry_dict['created'], '%Y-%m-%d')
        entry_dict['modified'] = datetime.strptime(entry_dict['modified'], '%Y-%m-%d')

        taxid = self.get_taxid(entry)

        if taxids is None or taxid in taxids:
            entry_dict = self.update_entry_dict(entry, entry_dict, taxid)
            entry_obj = models.Entry(**entry_dict)
            del entry_dict

            self.session.add(entry_obj)
801079
public function save()
    {
        $entries = $this->logBuffer->getEntries();

        $entrySkeleton = [
            'ts'    => $this->ts,
            'month' => $this->month,
            'year'  => $this->year
        ];

        $dimensionSkeleton = [
            'ts'    => $this->ts,
            'month' => $this->month,
            'year'  => $this->year
        ];

        /**
         * @var $e LogEntry
         */
        foreach ($entries as $e) {
            // build entry
            $entry = $entrySkeleton;
            $entry['entity'] = $e->getName();
            $entry['ref'] = $e->getRef();

            // check if we have attributes defined
            if (count($e->getAttributes()) > 0) {
                $entry['attributes'] = $e->getAttributes();
            }

            // insert or update the DAILY stat
            $this->mongo->update(self::ADB_STATS_DAILY, // match
                [
                    'entity' => $e->getName(),
                    'ref'    => $e->getRef(),
                    'ts'     => $this->ts
                ], // update
                [
                    '$inc'         => ['count' => $e->getIncrement()],
                    '$setOnInsert' => $entry
                ], // options
                ['upsert' => true]);

            // insert or update the MONTHLY stat
            unset($entry['ts']);
            $entry['month'] = $this->month;
            $entry['year'] = $this->year;
            $this->mongo->update(self::ADB_STATS_MONTHLY, // match
                [
                    'entity' => $e->getName(),
                    'ref'    => $e->getRef(),
                    'ts'     => $this->monthTs
                ], // update
                [
                    '$inc'         => ['count' => $e->getIncrement()],
                    '$setOnInsert' => $entry
                ], // options
                ['upsert' => true]);

            // insert dimensions for the entry
            $dimEntry = $dimensionSkeleton;
            $dimEntry['entity'] = $e->getName();

            /**
             * @var $dim LogDimension
             */
            foreach ($e->getDimensions() as $dim) {
                $dimEntry['name'] = $dim->getName();
                $dimEntry['value'] = $dim->getValue();

                $this->mongo->update(self::ADB_DIMS, // match
                    [
                        'name'   => $dim->getName(),
                        'value'  => $dim->getValue(),
                        'entity' => $e->getName(),
                        'ts'     => $this->ts
                    ], // update
                    [
                        '$inc'         => [
                            'count.' . $e->getRef() => $dim->getIncrement(),
                            'total'                 => $dim->getIncrement()
                        ],
                        '$setOnInsert' => $dimEntry
                    ], // options
                    ['upsert' => true]);
            }
        }

        // clear buffer
        $this->logBuffer = new LogBuffer();
    }
146474
public static function save()
    {
        try {
            $tableName = self::getTableName();
            $affectedRows = 0;
            $conn = self::getConnection();

            if(array_key_exists("id", self::$fields)){
                //update an existing record
                $sql = self::makeUpdateSQL();
            }
            else {
                //insert a new record
                $tableColumns = implode(", ", array_keys(self::$fields));
                $columnValues = "'".implode("', '", array_values(self::$fields))."'";
                $sql = "INSERT INTO ".$tableName."($tableColumns) VALUES($columnValues)";
            }

            $affectedRows = $conn->exec($sql);

            return $affectedRows;
        }
        catch(PDOException $pe) {
            return $pe->getMessage();
        }
        catch(Exception $e) {
            return $e->getMessage();
        }
    }
507236
def do_save(self, fp=None):
        
        if fp is not None:
            raise NotImplementedError()
        self.update_main_table()
        self.db.commit()