/** * Create a new record using the given criteria * @param array $data Key/Value pairs to use as data for new record i.e. array (field_name => value) * @return integer Returns the ID of the newly created record */ static function Create($data) { App::LoadClass('Privacy'); $db = Database::GetInstance(); $query = 'INSERT INTO ' . DB_PREFIX . self::$table; $fields = 'date_created, '; $values = "'" . gmdate(DATE_FORMAT) . "', "; Plugin::Trigger('user.before_create'); foreach ($data as $_key => $_value) { $fields .= "{$_key}, "; $values .= "'" . $db->Escape($_value) . "', "; } $fields = substr($fields, 0, -2); $values = substr($values, 0, -2); $query .= " ({$fields}) VALUES ({$values})"; $db->Query($query); Privacy::Create(array('user_id' => $db->LastId())); Plugin::Trigger('user.create'); return $db->LastId(); }