Load an existing object from the database
966242
protected function getExistingObject()
    {
        $state = StateQuery::create()
            ->findPk($this->getRequest()->get('state_id', 0))
        ;

        if (null !== $state) {
            $state->setLocale($this->getCurrentEditionLocale());
        }

        return $state;
    }
900353
def save_object_to_db(self,
                          obj: Any,
                          table: str,
                          fieldlist: Sequence[str],
                          is_new_record: bool) -> None:
        """"""
        if is_new_record:
            pkvalue = getattr(obj, fieldlist[0])
            if pkvalue is None:
                self.insert_object_into_db_pk_unknown(obj, table, fieldlist)
            else:
                self.insert_object_into_db_pk_known(obj, table, fieldlist)
        else:
            self.update_object_in_db(obj, table, fieldlist)
432496
def load_object(self, kwargs):
        """"""
        self.object = None
        self.config = None
        self.model = self.get_model_class()
        kwargs.pop('app', None)
        kwargs.pop('model', None)

        if self.model and kwargs.get('pk', False):
            try:
                self.object = self.model.objects.get(pk=kwargs.pop('pk'))
            except Exception:
                raise Exception("Could not load {}".format(self.model.__name__.lower()))
            setattr(self, self.model.__name__.lower(), self.object)

        return kwargs
1322923
def load(dbname, dbmode='a'):
    
    if dbmode == 'w':
        raise AttributeError("dbmode='w' not allowed for load.")
    db = Database(dbname, dbmode=dbmode)

    return db
1271207
public function load($id, Persistence $from_persistence = null)
    {
        if (!$from_persistence) {
            $from_persistence = $this->persistence;
        }

        if (!$from_persistence) {
            throw new Exception(['Model is not associated with any database']);
        }

        if ($this->loaded()) {
            $this->unload();
        }

        if ($this->hook('beforeLoad', [$id]) === false) {
            return $this;
        }

        $this->data = $from_persistence->load($this, $id);
        if (null === $this->id) {
            $this->id = $id;
        }

        $ret = $this->hook('afterLoad');
        if ($ret === false) {
            return $this->unload();
        } elseif (is_object($ret)) {
            return $ret;
        }

        return $this;
    }
1306633
def get_or_exception(cls, id):
        '''  '''
        obj = cls.get(id)

        if obj is None:
            raise ModelNotFoundError('This object does not exist in database')

        return obj
252795
def reload(self) -> None:
        """"""
        if not self.state_.is_persisted or self.state_.is_changed:
            raise InvalidStateError(f'`{self.__class__.__name__}` object is in invalid state')

        # Retrieve the entity's ID by the configured Identifier field
        identifier = getattr(self, self.meta_.id_field.field_name)
        logger.debug(f'Lookup `{self.__class__.__name__}` object with '
                     f'identifier {self.meta_.id_field}')

        # Fetch the entity data from db by its identifier
        db_value = self.get(identifier)

        # Update own data from fetched entity data
        # This allows us to ``dog.reload()`` instead of ``dog = dog.reload()``
        self._update_data(db_value.to_dict())
286617
function loadObject(dbProject, nodeHash) {
    var deferred = Q.defer(),
        node;

    dbProject.loadObject(nodeHash)
        .then(function (node_) {
            var shardLoads = [],
                shardId;
            node = node_;

            if (node && node.ovr && node.ovr.sharded === true) {
                for (shardId in node.ovr) {
                    if (REGEXP.DB_HASH.test(node.ovr[shardId]) === true) {
                        shardLoads.push(dbProject.loadObject(node.ovr[shardId]));
                    }
                }
                return Q.allSettled(shardLoads);
            } else {
                deferred.resolve(node);
                return;
            }
        })
        .then(function (overlayShardResults) {
            var i,
                response = {
                    multipleObjects: true,
                    objects: {}
                };
            response.objects[nodeHash] = node;

            for (i = 0; i < overlayShardResults.length; i += 1) {
                if (overlayShardResults[i].state === 'rejected') {
                    throw new Error('Loading overlay shard of node [' + nodeHash + '] failed');
                } else if (overlayShardResults[i].value._id) {
                    response.objects[overlayShardResults[i].value._id] = overlayShardResults[i].value;
                }
            }

            deferred.resolve(response);
        })
        .catch(deferred.reject);

    return deferred.promise;
}
939620
def _load(self, event):
        
        if not event.data:
            return

        context = self.context()
        schema = self.schema()
        dbname = schema.dbname()
        clean = {}

        for col, value in event.data.items():
            try:
                model_dbname, col_name = col.split('.')
            except ValueError:
                col_name = col
                model_dbname = dbname

            # make sure the value we're setting is specific to this model
            try:
                column = schema.column(col_name)
            except orb.errors.ColumnNotFound:
                column = None

            if model_dbname != dbname or (column in clean and isinstance(clean[column], Model)):
                continue

            # look for preloaded reverse lookups and pipes
            elif not column:
                self.__preload[col_name] = value

            # extract the value from the database
            else:
                value = column.dbRestore(value, context=context)
                clean[column] = value

        # update the local values
        with WriteLocker(self.__dataLock):
            for col, val in clean.items():
                default = val if not isinstance(val, dict) else val.copy()
                self.__values[col.name()] = (default, val)
                self.__loaded.add(col)

        if self.processEvent(event):
            self.onLoad(event)
1284340
def load_object(self, filename):
        

        """
        p = Path(filename)
        with open(p, 'rb') as f:
            d = pickle.load(f)
        obj = self._new_object(objtype=p.suffix.strip('.'),
                               name=p.name.split('.')[0])
        obj.update(d)
1100114
public function loadObject($params=array()) {

		$this->openConnection();
		
		$obj = NULL;
		
		try {
			
			$stat = $this->handler->prepare($this->query);
			$stat->execute((array)$params);
			$obj = $stat->fetch(\PDO::FETCH_OBJ);
			
			// logger
			$this->logParamQuery($this->query, (bool)$obj, $params);

		} catch (\PDOException $e) {

			$this->handleException($e, $params);
		
		}
		
		$stat->closeCursor();

		return $obj;
		
	}
22218
def load(self, id=None):
        """"""
        if id is not None:
            # We are asked to change our ID to something else
            self.reset()
            self._setID(id)
        if not self._new and self._validID():
            self._loadDB()
        self._updated = time.time()
1245639
def load_from_object(self, object_name):
        
        for key in dir(object_name):
            if key.isupper():
                self[key] = getattr(object_name, key)
873061
def add_object(self, object):
        """"""
        if object.id is None:
            object.get_id()
        self.db.engine.save(object)
535668
def prepare_object(obj, using="default"):
    
    model = obj.__class__
    unified_index = connections[using].get_unified_index()
    index = unified_index.get_index(model)
    prepped_data = index.full_prepare(obj)
    final_data = {}
    for key, value in prepped_data.items():
        final_data[key] = connections[using].get_backend()._from_python(value)
    return final_data
1065604
def load(json_src, save=False):
    """"""
    if isinstance(json_src, six.string_types):
        json_src = json_lib.loads(json_src)

    if isinstance(json_src, list):
        return [getattr(objects, obj['class']).load(obj, save)
                for obj in json_src]

    return getattr(objects, json_src['class']).load(json_src, save)
663273
def fetch_object_from_db_by_other_field(self,
                                            obj: Any,
                                            table: str,
                                            fieldlist: Sequence[str],
                                            keyname: str,
                                            keyvalue: Any) -> bool:
        """"""
        row = self.fetchone(
            get_sql_select_all_fields_by_key(table, fieldlist, keyname,
                                             self.get_delims()),
            keyvalue
        )
        if row is None:
            blank_object(obj, fieldlist)
            return False
        assign_from_list(obj, fieldlist, row)
        return True