INSERT the database record

@param  array  $eventData
@param  int    $peopleId   Primary ID of the peoples database table
@return bool
546661
public function createRecord($eventData, $peopleId) {

        // Basically, just want to throw the data to the "API", and have the database magically updated.
        // Don't want to do the Command Bus thing, although has worked out well! The data's ready, just
        // want to get to the persist.

        // Yeah, how good it would be to just get some DB statements to do the INSERTs, but... it is
        // important to see if I can use the "API" (the API Package) for the persist, because this
        // type of thing will be common in future development

        // We need to assemble the data needed for the persist, so let's create the data array
        $data = [];

        // We need the model's field list from the model
        $data['field_list'] = $this->model->field_list;

        // data from the event command bus DTO
        $data['email_type_id']         = 1;   // "Primary", per lookup_email_types
        $data['title']                 = $eventData->data['data']['email'];
        $data['description']           = "";
        $data['comments']              = "Automatically created during front-end registration,";

        // Pivot Tables
        // If there is NO record to INSERT into the pivot table, then the value is null.
        // If there is a record to INSERT into the pivot table, then use an ARRAY since multple values are acceptable,
        // and are specified in an array. For reference, the pivot table INSERTs @
        // Lasallecms\Lasallecmsapi\Repositories\Traits\persist::associateRelatedRecordsToNewRecord()
        $data['companies']            = null;
        $data['peoples'][]            = $peopleId;

        $saveok = $this->repository->createRecord($data);

        return $saveok;
    }
335304
public function isOwnedBy($recordId, $userId = null)
    {
        return (bool)$this->find()
            ->where(['id' => $recordId, 'user_id' => $userId])
            ->first();
    }
1277242
protected function insertDataToLine(string $data, string $filePath, int $lineNumber): bool
    {
        $lines = file($filePath);
        if ($lines === false) {
            return false;
        }

        if (count($lines) + 1 < $lineNumber) {
            $lineNumber = count($lines) + 1;
        }
        if ($lineNumber < 1) {
            $lineNumber = 1;
        }

        array_splice($lines, $lineNumber - 1, 0, [$data]);

        $result = file_put_contents($filePath, implode('', $lines));
        if ($result === false) {
            return false;
        }

        return true;
    }
448960
public function insertPDO($table, array $data = array())
    {
        if (count($data) === 0) {
            return false;
        }
        $q = "INSERT INTO `$table` ";
        $v = '';
        $n = '';

        foreach ($data as $key => $val) {
            $n .= "`$key`, ";
            if (strtolower($val) === 'now()') {
                $v .= 'NOW(), ';
                unset($data[$key]);
            } else {
                $v .= '?, ';
            }
        }
        $q .= '(' . rtrim($n, ', ') . ') VALUES (' . rtrim($v, ', ') . ');';
        try {
            $this->_queryId = self::$_linkId->prepare($q);

            $i = 1;
            foreach ($data as $key => $val) {
                $type = $this->getPDOConstantType($val);
                $this->_queryId->bindValue($i, $val, $type);
                ++$i;
            }
            $this->_queryId->execute();
            return self::$_linkId->lastInsertId();
        } catch (PDOException $e) {
            $this->_error = $e->getMessage();
            return false;
        }
    }
910247
public function insert($item, $cleanData = true)
    {
        $item       = $this->create($item);
        $connection = $this->getConnection();

        if ($cleanData) {
            $data = $this->cleanData($item->toArray());
        } else {
            $data = $item->toArray();
        }

        $connection->insert($this->tableName, $data);
        $item->setId($connection->lastInsertId());
        return $item;
    }
1096404
public function notifySubscribers(string $eventId, array $eventData)
    {
        /** @var SubscriberInterface $subscriber */
        foreach ($this->getSubscribers() as $subscriber) {
            $subscriber->handleEvent($eventId, $eventData);
        }
    }
7197
public function insert(array $data, string $id = null)
    {
        // Prepare query
        $query = $this->genInsert($data);
        $statement = $this->getInstance()->prepare($query);

        // Bind values
        foreach ($data as $key => $value) {
            $statement->bindValue(":$key", $value, $this->isPdoInt($value));
        }

        // Execute operation
        $statement->execute();

        return (null !== $id)
            // Return ID of inserted element
            ? $this->getInstance()->lastInsertId($id)
            // Return count of affected rows
            : $statement->rowCount();
    }
1028364
public static function insert($sqlstatement, array $data = [])
    {
        static::verifyConnection();

        if (!preg_match(
            "/^insert\s+into\s+[\w\d_-`]+\s?(\(.+\))?\s+(values\s?(\(.+\),?)+|\s?set\s+(.+)+);?$/i",
            $sqlstatement
        )) {
            throw new DatabaseException(
                'Syntax Error on the Request',
                E_USER_ERROR
            );
        }

        if (empty($data)) {
            $pdoStement = static::$adapter->getConnection()->prepare($sqlstatement);

            $pdoStement->execute();

            return $pdoStement->rowCount();
        }

        $collector = [];
        
        $r = 0;

        foreach ($data as $key => $value) {
            if (is_array($value)) {
                $r += static::executePrepareQuery($sqlstatement, $value);

                continue;
            }

            $collector[$key] = $value;
        }

        if (!empty($collector)) {
            return static::executePrepareQuery($sqlstatement, $collector);
        }

        return $r;
    }
105544
protected function dispatchInsert($item, $eventData = array()) {
    return $this->manager->dispatchEvent(self::EVENT_INSERT, array_merge(array('item'=>$item), $eventData), $this);
  }
841966
public function addRow($data, $rowId = null)
    {
        if (($rowId === null) && isset($data['id'])) {
            $rowId = $data['id'];
        }

        if ($rowId === null) {
            $rowId = count($this->rows);
        }

        $this->rows[$rowId] = $data;

        return $this;
    }
357
public static function add_contact(int $userid, int $contactid) {
        global $DB;

        $messagecontact = new \stdClass();
        $messagecontact->userid = $userid;
        $messagecontact->contactid = $contactid;
        $messagecontact->timecreated = time();
        $messagecontact->id = $DB->insert_record('message_contacts', $messagecontact);

        $eventparams = [
            'objectid' => $messagecontact->id,
            'userid' => $userid,
            'relateduserid' => $contactid,
            'context' => \context_user::instance($userid)
        ];
        $event = \core\event\message_contact_added::create($eventparams);
        $event->add_record_snapshot('message_contacts', $messagecontact);
        $event->trigger();
    }
1276346
public function createNew(array $authData, array $userData) {
        // first save the new user
        $userModel  = new Model_User();
        $userId     = $userModel->insert($userData);
        $userData   = $userModel->find($userId)->current();
        $authData['user_id'] = $userId;
        $this->insert($authData);

        $this->getObserver('Authenticatable')->updateLoginStats($userId);
        return $userData;
    }
950453
protected function doInsert($sid, $data, $uid=null) {
		if(is_array($data)) {
			$data = serialize($data);
		}
		
		$sqlData = array(
			'session_id'	=> $sid,
			'session_data'	=> $data
		);
		if(!is_null($uid) && strlen($uid)) {
			$sqlData['uid'] = $uid;
		}
		elseif(!is_null($uid) && !strlen($uid)) {
			// no data in UID; it was specifically supplied empty, make it null in DB
			$sqlData['uid'] = null;
		}
		
		try {
			$sql = 'INSERT INTO '. self::tableName .' '. $this->create_sql_insert_string($sqlData);

			$rowsInserted = $this->db->run_query($sql, $sqlData);
			if($rowsInserted != 1) {
				throw new exception(__METHOD__ .": failed to insert data, rows inserted=(". $rowsInserted .")");
			}
		}
		catch(Exception $e) {
			$this->exception_handler($e->getMessage());
		}
		
		return($sid);
	}
351649
public function insert($table, array $data)
    {
        $nameFields = join(',', array_keys($data));
        $preparedValues = $this->prepareValues($data);
        $keyValues = join(",", array_keys($preparedValues));
        $queryString = "INSERT INTO {$table} ({$nameFields}) VALUES ({$keyValues});";

        $this->query($queryString, $preparedValues);

        return $this->getInsertId();
    }
69321
private function saveEvent($websiteId, $storeId, $type, $entityId, $data)
    {
        $data = $this->json->serialize($data);

        /** @var EventModel $eventModel */
        $eventModel = $this->eventFactory->create()
            ->setEntityId($entityId)
            ->setWebsiteId($websiteId)
            ->setStoreId($storeId)
            ->setEventType($type)
            ->setEventData($data);

        $this->eventRepository->save($eventModel);
    }
1256894
public function create($userId=null, $eventLog=null, $eventData=null)
    {
        if(is_null($userId)) throw new \Exception('User ID is required.');
        if(is_null($eventLog)) throw new \Exception('Event Log is required.');
        if(!is_numeric($userId)) throw new \Exception("Invalid User ID.");

        $id = $this->save($this->generateEntity(intval($userId), $eventLog, $eventData));
        return $id;
    }
703063
public function insert(array $data) {
        $statement = new InsertStatement($data);
        $statement->setStatementContext($this->statementContext);
        $sql = $statement->parse();

        $result = $this->connection->execute($sql, $this->statementContext->getParameters());

        $this->clear();

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

        return $this->connection->lastInsertId();
    }