save

@access public
@return int
321877
public function save()
    {
        $sQuery = $this->_prepare();

        if (preg_match('/INSERT INTO/i', $sQuery)) {

            $oDb = self::connect();

            if (!$oDb->exec($sQuery)) {
                error_log($sQuery."\n".print_r($oDb->errorInfo(), true));
            }

            $this->flush();
            return $oDb->lastInsertId();
        }
        else {

            $this->flush();

            if ($this->_mWhere instanceof Where) { $this->_mWhere->flush(); }

            return self::connect()->exec($sQuery);
        }

    }
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();
        }
    }
984960
public function save()
    {
        foreach ($this->_update as $mbox => $val) {
            try {
                if (!empty($val['u'])) {
                     $ptr = &$this->_data[$mbox];
                     foreach ($this->_getMsgCids($mbox, array_keys($val['u'])) as $k2 => $v2) {
                         try {
                             $this->_hash->set(
                                 $v2,
                                 $this->_pack->pack($ptr[$k2]),
                                 array('expire' => $this->_params['lifetime'])
                             );
                         } catch (Horde_Pack_Exception $e) {
                             $this->deleteMsgs($mbox, array($v2));
                             $val['d'][] = $v2;
                         }
                     }
                 }

                 if (!empty($val['d'])) {
                     $this->_hash->delete(array_values(
                         $this->_getMsgCids($mbox, $val['d'])
                     ));
                 }

                 if (!empty($val['m'])) {
                     try {
                         $this->_hash->set(
                             $this->_getCid($mbox),
                             $this->_pack->pack($this->_mbox[$mbox]),
                             array('expire' => $this->_params['lifetime'])
                         );
                     } catch (Horde_Pack_Exception $e) {}
                 }
            } catch (Horde_Exception $e) {
            }
        }

        $this->_update = array();
    }
1303452
protected function save()
    {
        $filename = Path::create([$this->outputPath(), $this->outputFile()]);

        return (bool) \file_put_contents($filename->toString(), $this->stub);
    }
1186872
public function save()
    {
        $array = $this->toArrayWithoutEmptyValues();

        $query = $this->createQuery();

        $now = (new \DateTime())->format('Y-m-d H:i:s');

        if ($this->{$this->getTableKey()}) {
            $query->setAction('update');
            $query->where($query->buildAndSet([
                [$this->getTableKey(), "=", $this->id],
            ]));

            foreach ($array as $key => $value) {
                $query->addValue($key, $value);
            }

            // Since it's an update, add updated_at if the model implements it
            if (property_exists($this, 'updated_at')) {
                $query->addValue('updated_at', $now);
                $this->updated_at = $now;
            }
        } else {
            $query->setAction('insert');

            foreach ($array as $key => $value) {
                if ($key !== $this->tableKey) {
                    $query->addValue($key, $value);
                }
            }

            // Since it's an insert, add created_at if the model implements it
            if (property_exists($this, 'created_at')) {
                $query->addValue('created_at', $now);
                $this->created_at = $now;
            }
        }
        $result = $this->database->query($query);
        if ($result && $query->getAction() === 'insert') {
            $this->id = $this->database->getInstance()->lastInsertId();
        }
        return $result ? true : false;
    }
1003359
public function save(){
		$json	= $this->data->toJson();
		if( $this->format )
			$json	= ADT_JSON_Formater::format( $json );
		return FS_File_Writer::save( $this->fileName, $json );
	}
95178
public function save()
    {
        $ok = $this->consumer->getStorage()->resourceLinkSave($this);
        if ($ok) {
            $this->settingsChanged = false;
        }

        return $ok;
    }
644205
public function save() :bool {
		
		// if an id already exists
		if($this->_['id']) {
			// we can update and return the number of affected rows (0 on error, 1 on success)
			return (bool) self::_update()
				->set($this->__toArray(true, true))
				->where(['id'=>$this->_['id']])
				->execute();
		}
		// this is a new record
		else {
			// try to insert it
			$inserted_object = self::create($this->__toArray(true, true));
			// if insertion succeeded, return true
			if($inserted_object) {
				// clone ourselves with what the database returneds, a full fledged object
				$this->replicate($inserted_object);
				// return success
				return true;
			}
			// didnt insert
			else {
				// failure feedback
				return false;
			}
		}
		
	}
213860
public function save()
    {
        if ( ! $this->isSaved()) {
            $this->write($this->data);
            $this->unsaved = false;
        }

        return $this;
    }
319164
function save()
    {
        if ($this->id != false || $this->id != 0) {
            return $this->update();
        } else {
            return $this->insert();
        }
    }
363203
public function save()
    {
        event(new BeforeSave($this));

        $this->beforeSave();

        $this->doSave();

        $this->afterSave();

        event(new AfterSave($this));
    }
797396
public function save()
    {
        $query = new QueryBuilder(self::$_connection);

        if($this->_isInsert) {
            $query->insert($this->getTable())
                  ->values($this->_changed);

            $id = self::$_connection->insert($query->getQuery());
            $this->_data[$this->_primaryKey] = $id;

            $this->_isInsert = false;
            $this->_changed  = [];

            return;
        }

        $query->update($this->getTable())
              ->set($this->_changed)
              ->where([
                  $this->_primaryKey => $this->_data[$this->_primaryKey]
              ])
              ->execute();

        $this->_changed = [];
    }
1240479
public function save()
    {
        // Grab the directory and create it if needed
        $info = pathinfo($this->fname);
        $dir  = $info['dirname'];

        if (!is_dir($dir)) {
            // dir doesn't exist, make it
          mkdir($dir, 0777, true);
        }


        return file_put_contents($this->fname, json_encode($this->data));
    }
1248190
public function save () {
		if (isset ($this->_data['id'])) {
			return $this->_send_and_receive ($this->site . $this->element_name_plural . '/' . $this->_data['id'] . '.xml', 'PUT', $this->_data); // update
		}
		return $this->_send_and_receive ($this->site . $this->element_name_plural . '.xml', 'POST', $this->_data); // create
	}
1371781
public function save()
	{
		$sQuery = $this->_prepare();

		if (preg_match('/INSERT INTO/i', $sQuery)) {

			$oDb = self::connect();
			$oDb->exec($sQuery);
			$this->flush();
			return $oDb->lastInsertId();
		}
		else {

			$this->flush();

			if ($this->_mWhere instanceof Where) { $this->_mWhere->flush(); }

			return self::connect()->exec($sQuery);
		}

	}
645207
public function save()
    {
        if ($this->_isSaved) {
            $this->update($this->id);
        } else {
            $this->id = $this->insert();
            $this->_isSaved = true;
        }
    }
67246
public static final function save() {
        foreach (self::$dirty as $class => $true) {
            self::$instances[$class]->store();
            unset(self::$dirty[$class]);
        }
    }