Create a new entry in the profiles table

@return  boolean  True on success, False on error
173028
public function create()
	{
		$db = \App::get('db');

		$modifiedDate = gmdate('Y-m-d H:i:s');

		if (is_numeric($this->get('uidNumber')))
		{
			$query = "INSERT INTO `#__xprofiles` (uidNumber,username,modifiedDate) VALUE (" . $db->quote($this->get('uidNumber')) . ',' . $db->quote($this->get('username')) . ',' . $db->quote($modifiedDate) . ");";

			$db->setQuery($query);

			if (!$db->query())
			{
				$errno = $db->getErrorNum();

				if ($errno == 1062)
				{
					$this->setError('uidNumber (' . $this->get('uidNumber') . ') already exists' . ' in xprofiles table');
				}
				else
				{
					$this->setError('Error inserting user data to xprofiles table: ' . $db->getErrorMsg());
				}

				return false;
			}
		}
		else
		{
			$token = uniqid();

			$query = "INSERT INTO `#__xprofiles` (uidNumber,username,modifiedDate) SELECT " . "IF(MIN(uidNumber)>0,-1,MIN(uidNumber)-1)," . $db->quote($token) . ',' . $db->quote($modifiedDate) . " FROM #__xprofiles;";

			$db->setQuery($query);

			if (!$db->query())
			{
				$this->setError('Error inserting non-user data to xprofiles table: ' . $db->getErrorMsg());

				return false;
			}

			$query = "SELECT uidNumber FROM `#__xprofiles` WHERE username=" . $db->quote($token) . " AND modifiedDate=" . $db->quote($modifiedDate);

			$db->setQuery($query);

			$result = $db->loadColumn();

			if ($result === false)
			{
				$this->setError('Error adding data to xprofiles table: ' . $db->getErrorMsg());

				return false;
			}

			if (count($result) > 1)
			{
				$this->setError('Error adding data to xprofiles table: ' . $db->getErrorMsg());

				return false;
			}

			$this->set('uidNumber', $result[0]);
		}

		$this->set('modifiedDate', $modifiedDate);

		if ($this->update() === false)
		{
			return false;
		}

		return true;
	}
379962
public static function createSentry()
	{
		// Get some resources
		$ci =& get_instance();
		$ci->load->driver('session');

		// If Eloquent doesn't exist, then we must assume they are using their own providers.
		if (class_exists('Illuminate\Database\Eloquent\Model'))
		{
			$ci->load->database();

			// Let's connect and get the PDO instance
			$method = $ci->db->pconnect ? 'db_pconnect' : 'db_connect';
			$pdo = $ci->db->{$method}();

			// Validate PDO
			if ( ! $pdo instanceof PDO)
			{
				throw new \RuntimeException("Sentry will only work with PDO database connections.");
			}

			// Setup PDO
			foreach (static::$pdoOptions as $key => $value)
			{
				$pdo->setAttribute($key, $value);
			}

			$driverName  = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
			$tablePrefix = substr($ci->db->dbprefix('.'), 0, -1);

			Eloquent::setConnectionResolver(new ConnectionResolver($pdo, $driverName, $tablePrefix));
		}

		return new BaseSentry(
			$userProvider = new UserProvider(new NativeHasher),
			new GroupProvider,
			new ThrottleProvider($userProvider),
			new CISession($ci->session),
			new CICookie($ci->input),
			$ci->input->ip_address()
		);
	}
842178
public function create () : bool
	{
        $dbObject 	= Database::getInstance();
		$attributes = $this->sanitizedAttributes();
		$sqlQuery	= "INSERT INTO ".static::$tableName." (";
		$sqlQuery  .= join(", ", array_keys($attributes));
	  	$sqlQuery  .= ") VALUES ('";
		$sqlQuery  .= join("', '", array_values($attributes));
		$sqlQuery  .= "')";
		$result 	= $dbObject->query($sqlQuery);
    	$this->id 	= $dbObject->insertId();
    	return ($result) ? TRUE : FALSE;
	}
321276
public function isCreate()
    {
        $primary = $this->primaryKey();
        foreach ($primary as $column) {
            if (!empty($this->_context['defaults'][$column])) {
                return false;
            }
        }

        return true;
    }
717840
public function create()
	{
		$db = \App::get('db');

		if (empty($db))
		{
			return false;
		}

		$cn = $this->cn;
		$gidNumber = $this->gidNumber;

		if (empty($cn) && empty($gidNumber))
		{
			return false;
		}

		if (is_numeric($gidNumber))
		{
			if (empty($cn))
			{
				$cn = '_gid' . $gidNumber;
			}

			$query = "INSERT INTO `#__xgroups` (gidNumber,cn) VALUES (" . $db->quote($gidNumber) . "," . $db->quote($cn) . ");";

			$db->setQuery($query);

			$result = $db->query();

			if ($result === false && $db->getErrorNum() != 1062)
			{
				return false;
			}
		}
		else
		{
			$query = "INSERT INTO `#__xgroups` (cn) VALUES (" . $db->quote($cn) . ");";

			$db->setQuery($query);

			$result = $db->query();

			if ($result === false && $db->getErrorNum() == 1062) // row exists
			{
				$query = "SELECT gidNumber FROM `#__xgroups` WHERE cn=" . $db->quote($cn) . ";";

				$db->setQeury($query);

				$result = $db->loadResult();

				if (empty($result))
				{
					return false;
				}

				$this->__set('gidNumber', $result);
			}
			else if ($result !== false)
			{
				$this->__set('gidNumber', $db->insertid());
			}
			else
			{
				return false;
			}
		}

		//trigger the onAfterStoreGroup event
		\Event::trigger('user.onAfterStoreGroup', array($this));

		return $this->gidNumber;
	}
521373
public function add()
    {
        $user = $this->Users->newEntity();
        if ($this->request->is('post')) {
            $user = $this->Users->patchEntity($user, $this->request->getData());
            if (Filter::bool($user->get('notify'))) {
                $user->set('token', Token::generate());
            }

            $result = $this->Users->save($user);
            if ($result) {
                $this->Flash->success(__d('community', 'The user {0} has been saved.', sprintf(
                    '<strong>«%s»</strong>',
                    $result->get('login')
                )));

                return $this->App->redirect(['apply' => ['action' => 'edit', $result->id]]);
            } else {
                $this->Flash->error(__d('community', 'User could not be updated. Please, try again.'));
            }
        }

        $groups = $this->Users->Groups->getTreeList();

        $this
            ->set(compact('user', 'groups'))
            ->set('page_title', __d('community', 'Profiles: Add new user'));
    }
554871
protected function buildProfile() {
		$sql = "SELECT * FROM {$this->primaryTable} WHERE id=:id";
		if ($user = $this->executeQuery($sql,array(":id"=>$this->getSessionUserId()))[0]) {
			unset($user['password']);
			foreach ($user as $field=>$value) {
				$this->profile[$field] = $value;
			}
		}
	}
1284667
public function actionCreate()
    {
        $this->layout = static::FORM_LAYOUT;
        $model = new $this->MainModel;

        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            if(empty($model->Menu_id)) {
                Yii::info('Making the new node as root');
                $model->makeRoot();
            } else {
                $parent_node = Menu::findOne($model->Menu_id);
                $model->appendTo($parent_node);

                Yii::info('Making the new node as a child of ' . $parent_node->id);
            }
            $this->saveHistory($model, $this->historyField);
            return $this->redirect(['index']);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }
102551
public function createAction()
    {
        $success    = null;
        $params     = $this->params();
        $request    = $this->getRequest();
        $type       = $params->fromRoute( 'type' );
        $parent     = $params->fromRoute( 'parentId', null );
        $menu       = $this->getModel()
                           ->create( array(
                                'type' => $type,
                            ) );

        $form = $this->getForm( $menu );

        if ( $request->isPost() )
        {
            $form->setData( $request->getPost() );

            if ( $form->isValid() && $menu->save() &&
                 ( empty( $parent ) || $this->getModel()
                                            ->appendTo( $menu->id, $parent ) ) )
            {
                $success = true;

                $this->messenger()
                     ->add( 'menu.form.success',
                            'menu', Message::LEVEL_INFO );
            }
            else
            {
                $success = false;

                $this->messenger()
                     ->add( 'menu.form.failed',
                            'menu', Message::LEVEL_ERROR );
            }
        }

        return array(
            'success'   => $success,
            'form'      => $form,
            'menu'      => $menu,
        );
    }
267457
public function create()
    {
        $roles = Role::getAllLists();
        $parents = NavigationAdmin::getAllLists();

        return $this->view('titan::settings.navigation.add_edit')
            ->with('roles', $roles)
            ->with('parents', $parents);
    }
228976
public function create()
    {
        if (!userHasPermission('admin:invoice:customer:create')) {
            unauthorised();
        }

        $oInput = Factory::service('Input');
        if ($oInput->post()) {

            try {

                $this->formValidation();
                $oCustomerModel = Factory::model('Customer', 'nails/module-invoice');
                if (!$oCustomerModel->create($this->prepPostData())) {
                    throw new NailsException('Failed to create item. ' . $oCustomerModel->lastError(), 1);
                }

                $oSession = Factory::service('Session', 'nails/module-auth');
                $oSession->setFlashData('success', 'Item created successfully.');
                redirect('admin/invoice/customer');

            } catch (\Exception $e) {
                $this->data['error'] = $e->getMessage();
            }
        }

        $this->data['page']->title = 'Create customer';
        Helper::loadView('edit');
    }
917571
public function postCreate()
    {

        // Check if we should store creations in our revision history
        // Set this value to true in your model if you want to
        if(empty($this->revisionCreationsEnabled))
        {
            // We should not store creations.
            return false;
        }

        if ((!isset($this->revisionEnabled) || $this->revisionEnabled))
        {
            $revisions[] = array(
                'revisionable_type' => $this->getMorphClass(),
                'revisionable_id' => $this->getKey(),
                'key' => self::CREATED_AT,
                'old_value' => null,
                'new_value' => $this->{self::CREATED_AT},
                'user_id' => $this->getSystemUserId(),
                'created_at' => new \DateTime(),
                'updated_at' => new \DateTime(),
            );

            $revision = static::newModel();
            \DB::table($revision->getTable())->insert($revisions);
        }
    }
655552
public function create()
	{
		$db = \App::get('db');

		if (empty($db))
		{
			return false;
		}

		if (is_numeric($this->id))
		{
			$query = "INSERT INTO `#__trac_project` (id,name) VALUES ( " . $db->quote($this->id) . "," . $db->quote($this->name) . ");";
			$db->setQuery($query);

			$result = $db->query();

			if ($result !== false || $db->getErrorNum() == 1062)
			{
				return true;
			}
		}
		else
		{
			$query = "INSERT INTO `#__trac_project` (name) VALUES ( " . $db->quote($this->name) . ");";

			$db->setQuery($query);

			$result = $db->query();

			if ($result === false && $db->getErrorNum() == 1062)
			{
				$query = "SELECT id FROM `#__trac_project` WHERE name=" . $db->quote($this->name) . ";";

				$db->setQuery($query);

				$result = $db->loadResult();

				if ($result == null)
				{
					return false;
				}

				$this->id = $result;
				return true;
			}
			else if ($result !== false)
			{
				$this->id = $db->insertid();
				return true;
			}
		}

		return false;
	}
1365853
public function create()
    {
        if ($this->scenario != self::SCENARIO_CREATE) {
            return false;
        }

        if (!$this->validate()) {
            return false;
        }

        $rule = \Yii::createObject([
            'class' => $this->class,
            'name'  => $this->name,
        ]);
        
        $this->authManager->add($rule);
        $this->authManager->invalidateCache();
        
        return true;
    }
1000365
public function create()
    {
        // Validate form
        $form = $this->getForm('Create' . $this->getEntityName());
        if (!$form->isValid()) {
            return false;
        }

        // Insert new entity
        $now    = new \DateTime();
        $entity = $form->getData();
        $entity->setLastModified($now);
        $entity->setCreated($now);

        // Trigger oncreate
        $this->onCreate($entity);

        // Save
        $this->getEntityManager()->persist($entity);
        return $this->save($this->getEntityName() . ' created.', 'Unable to create ' . strtolower($this->getEntityName()) . '.');
    }
683860
public function createUser()
    {
        if ($this->getIsNewRecord() == false) {
            throw new \RuntimeException('Calling "' . __CLASS__ . '::' . __METHOD__ . '" on existing user');
        }
        $this->password = $this->password == null ? PasswordHelper::generate(8) : $this->password;
        $this->trigger(self::BEFORE_CREATE);
        if (!$this->save()) {
            return false;
        }
        $this->trigger(self::AFTER_CREATE);
        return true;
    }
568597
protected function createTableIfNeeded()
    {
        if ($this->tableExists) {
            return false;
        }

        if ($this->tableExist($this->tableName)) {
            $this->tableExists = true;
            return false;
        }

        $this->createTable();

        $this->tableExists = true;
        return true;
    }