create() protected méthode

Saves the base information in the entities table for the entity. Saving the type-specific information is handled in the calling class method.
protected create ( ) : integer
Résultat integer The new entity's GUID
Exemple #1
0
 /**
  * {@inheritdoc}
  */
 protected function create()
 {
     global $CONFIG;
     $guid = parent::create();
     $name = sanitize_string($this->name);
     $username = sanitize_string($this->username);
     $password = sanitize_string($this->password);
     $salt = sanitize_string($this->salt);
     $email = sanitize_string($this->email);
     $language = sanitize_string($this->language);
     $query = "INSERT into {$CONFIG->dbprefix}users_entity\n\t\t\t(guid, name, username, password, salt, email, language)\n\t\t\tvalues ({$guid}, '{$name}', '{$username}', '{$password}', '{$salt}', '{$email}', '{$language}')";
     $result = $this->getDatabase()->insertData($query);
     if ($result === false) {
         // TODO(evan): Throw an exception here?
         return false;
     }
     return $guid;
 }
Exemple #2
0
 /**
  * {@inheritdoc}
  */
 protected function create()
 {
     global $CONFIG;
     $guid = parent::create();
     if (!$guid) {
         // @todo this probably means permission to create entity was denied
         // Is returning false the correct thing to do
         return false;
     }
     $title = sanitize_string($this->title);
     $description = sanitize_string($this->description);
     $query = "INSERT into {$CONFIG->dbprefix}objects_entity\n\t\t\t(guid, title, description) values ({$guid}, '{$title}', '{$description}')";
     $result = $this->getDatabase()->insertData($query);
     if ($result === false) {
         // TODO(evan): Throw an exception here?
         return false;
     }
     return $guid;
 }
Exemple #3
0
 /**
  * {@inheritdoc}
  */
 protected function create()
 {
     global $CONFIG;
     $guid = parent::create();
     $name = sanitize_string($this->name);
     $description = sanitize_string($this->description);
     $query = "INSERT into {$CONFIG->dbprefix}groups_entity" . " (guid, name, description) values ({$guid}, '{$name}', '{$description}')";
     $result = $this->getDatabase()->insertData($query);
     if ($result === false) {
         // TODO(evan): Throw an exception here?
         return false;
     }
     return $guid;
 }
Exemple #4
0
 /**
  * {@inheritdoc}
  */
 protected function create()
 {
     global $CONFIG;
     $guid = parent::create();
     $name = sanitize_string($this->attributes['name']);
     $description = sanitize_string($this->attributes['description']);
     $url = sanitize_string($this->attributes['url']);
     $query = "INSERT into {$CONFIG->dbprefix}sites_entity\n\t\t\t(guid, name, description, url) values ({$guid}, '{$name}', '{$description}', '{$url}')";
     $result = $this->getDatabase()->insertData($query);
     if ($result === false) {
         // TODO(evan): Throw an exception here?
         return false;
     }
     // make sure the site guid is set to self if not already set
     if (!$this->site_guid) {
         $this->site_guid = $guid;
         $this->getDatabase()->updateData("UPDATE {$CONFIG->dbprefix}entities\n\t\t\t\tSET site_guid = {$guid} WHERE guid = {$guid}");
     }
     return $guid;
 }
Exemple #5
0
 /**
  * {@inheritdoc}
  */
 protected function create()
 {
     $guid = parent::create();
     if (!$guid) {
         // @todo this probably means permission to create entity was denied
         // Is returning false the correct thing to do
         return false;
     }
     $dbprefix = elgg_get_config('dbprefix');
     $query = "INSERT INTO {$dbprefix}objects_entity\n\t\t\t(guid, title, description)\n\t\t\tVALUES\n\t\t\t(:guid, :title, :description)";
     $params = [':guid' => (int) $guid, ':title' => (string) $this->title, ':description' => (string) $this->description];
     $result = $this->getDatabase()->insertData($query, $params);
     if ($result === false) {
         // TODO(evan): Throw an exception here?
         return false;
     }
     return $guid;
 }
Exemple #6
0
 /** @override */
 protected function create()
 {
     global $CONFIG;
     $guid = parent::create();
     $title = sanitize_string($this->title);
     $description = sanitize_string($this->description);
     $query = "INSERT into {$CONFIG->dbprefix}objects_entity\n\t\t\t(guid, title, description) values ({$guid}, '{$title}', '{$description}')";
     $result = insert_data($query);
     if ($result === false) {
         // TODO(evan): Throw an exception here?
         return false;
     }
     return $guid;
 }
Exemple #7
0
 /** @override */
 protected function create()
 {
     global $CONFIG;
     $guid = parent::create();
     $name = sanitize_string($this->attributes['name']);
     $description = sanitize_string($this->attributes['description']);
     $url = sanitize_string($this->attributes['url']);
     $query = "INSERT into {$CONFIG->dbprefix}sites_entity\n\t\t\t(guid, name, description, url) values ({$guid}, '{$name}', '{$description}', '{$url}')";
     $result = insert_data($query);
     if ($result === false) {
         // TODO(evan): Throw an exception here?
         return false;
     }
     return $guid;
 }