Add  data to table
@param $data
@return string
546122
static public function add($data)
    {
        try {
            $model = new static;
            $attributes = array_flip($model->attributes);
            $data = array_filter($data, function ($data) use ($attributes) {
                return isset($attributes[$data]);
            }, ARRAY_FILTER_USE_KEY);
            $sql = 'INSERT INTO '.$model->table.' (';
            foreach ($data as $column => $value) {
                $sql .= '`'.$column.'`, ';
            }
            $sql = trim($sql, ', ');
            $sql .= ') VALUES (';
            foreach ($data as $column => $value) {
                $sql .= ':'.$column.', ';
            }
            $sql = trim($sql, ', ');
            $sql .= ')';
            $statement = $model->connect->prepare($sql);
            foreach ($data as $column => $value) {
                $statement->bindValue(':'.$column, $value);
            }
            try {
                $statement->execute();
                return $model->connect->lastInsertId();
            } catch(\PDOExecption $e) {
                $model->connect->rollback();
                return "Error" . $e->getMessage();
            }
        } catch( \PDOExecption $e ) {
            return "Error" . $e->getMessage();
        }
    }
133546
public function addDomain($data)
    {
        if ($data instanceof Domain) {
            $domain = $data; // alias
            $domain->setDatabase($this);
            $this->domainMap[$domain->getName()] = $domain;

            return $domain;
        } else {
            $domain = new Domain();
            $domain->setDatabase($this);
            $domain->loadFromXML($data);

            return $this->addDomain($domain); // call self w/ different param
        }
    }
1143643
public function add(array $data)
    {
        $result = null;
        $this->hook->attach('category.add.before', $data, $result, $this);

        if (isset($result)) {
            return (int) $result;
        }

        $result = $data['category_id'] = $this->db->insert('category', $data);

        $this->setTranslations($data, $this->translation_entity, 'category', false);
        $this->setImages($data, $this->file, 'category');
        $this->setAlias($data, $this->alias, 'category', false);

        $this->hook->attach('category.add.after', $data, $result, $this);
        return (int) $result;
    }
460921
public function updateOrInsert($data)
    {
        if ($this->first()) {
            return $this->update($data);
        } else {
            return $this->insert($data);
        }
    }
912706
public function format(&$data) {
		$data = $this->normalize($data);
		$data = $this->convertToString($data);

		return $data;
	}
160963
public function insert($data)
    {
        $row = $this->getTable()->insert($data);
        if (!$row instanceof IRow) {
            return $row;
        }

        if ($this->auditLogRepository) {
            $to = $this->filterValues($this->excludeColumns((array)$data));

            $data = [
                'version' => '1',
                'from' => [],
                'to' => $to,
            ];
            $this->pushAuditLog(AuditLogRepository::OPERATION_CREATE, $row->getSignature(), $data);
        }

        return $row;
    }
868587
public function appendDataBuffer($data)
    {
        if (is_null($this->dataBuffer)) {
            $this->dataBuffer = $data;
        } else {
            $this->dataBuffer .= $data;
        }
        return $this;
    }
305212
public function save($data)
    {
        if (empty($data['_id'])) {
            return $this->insert($data);
        }

        $id = $data['_id'];

        unset($data['_id']);

        $bucketName = $this->db->quoteBucketName($this->name);

        $this->update($data, ["META($bucketName).id" => $id]);

        return $id;
    }
586222
public function put($data)
    {
        $this->data = array_merge($this->data, $data);
        return $this->save();
    }
602095
protected function prepareInsertData(array $data)
    {
        $dbData       = [];
        $extraColumns = $this->extraColumns ? $this->extraColumns : [];

        foreach ($data as $key => $value) {
            $dbData[] = array_merge($extraColumns, [
                $this->keyColumn   => $key,
                $this->valueColumn => $value,
            ]);
        }

        return $dbData;
    }
1114525
public function writeData($data)
	{
		if (strlen($data) - 4 > $this->_limit) {
			$data = $this->_addContinue($data);
		}
		$this->_datasize += strlen($data);

		return $data;
	}
1179172
public function insertNewRecord($data) {

        $emailMessage = new Email_message;

        $emailMessage->user_id             = $data['user_id'];
        $emailMessage->priority_id         = $data['priority_id'];
        $emailMessage->from_email_address  = $data['from_email_address'];
        $emailMessage->from_name           = $data['from_name'];
        $emailMessage->to_email_address    = $data['to_email_address'];
        $emailMessage->to_name             = $data['to_name'];
        $emailMessage->subject             = $data['subject'];
        $emailMessage->slug                = $data['slug'];
        $emailMessage->body                = $data['body'];
        $emailMessage->sent                = $data['sent'];
        $emailMessage->sent_timestamp      = $data['sent_timestamp'];
        $emailMessage->read                = $data['read'];
        $emailMessage->archived            = $data['archived'];
        $emailMessage->created_at          = $data['created_at'];
        $emailMessage->created_by          = $data['created_by'];
        $emailMessage->updated_at          = $data['updated_at'];
        $emailMessage->updated_by          = $data['updated_by'];

        if ($emailMessage->save()) {

            // Return the new ID
            return $emailMessage->id;
        }

        return false;
    }
763957
function insert($data)
    {
        $field = "";
        $values = "";

        foreach($data as $key => $value)
        {
            $value = $this->db->quote($value);
            $field = $field . "`$key`,";
            $values = $values . "'$value',";
        }

        $field = substr($field, 0, -1);
        $values = substr($values, 0, -1);
        return $this->db->query("insert into {$this->table} ($field) values($values)");
    }
762475
public function append($data)
    {
        $content = file_get_contents($this->_filleFullName);
        $data = $content.PHP_EOL.$data;
        $saveToFileRes = file_put_contents($this->_filleFullName, $data);
        return $saveToFileRes;
    }
1301427
public function insert(array $data)
    {
        if (isset($data['id'])) {
            if (array_key_exists($data['id'], $this->table->data['data'])) {
                return null;
            }
        } else {
            $data = ['id' => $this->generateId()] + $data;
        }

        $this->table->data['data'][$data['id']] = $data;
        $this->table->save();

        return $data['id'];
    }
1004090
public function insertUpdate(array $data)
    {
        $affected = $this->update($data);
        return $affected ?: $this->insert($data);
    }
1320070
public static function toString($data)
    {
        if (is_array($data)) {
            $newData = [];
            foreach ($data as $key => $val) {
                $key = (string)$key;
                $newData[$key] = static::toString($val);
            }
        } else {
            $newData = (string)$data;
        }

        return $newData;
    }