lib/models/ObjectFamiliarity.php
public static function created($object, $user = null)
    {
        $objectId = $object->id;
        $objectModel = addslashes($object->modelAlias);
        if (is_null($user) and isset(Yii::$app->user)) {
            $user = Yii::$app->user->id;
        }
        if (is_object($user)) {
            $user = $user->primaryKey;
        }
        if (empty($user) or empty(Yii::$app->session)) {
            return false;
        }
        $session = Yii::$app->session->id;

        $tableName = self::tableName();
        $familiarityUp = self::CREATED_FAMILIARITY;
        $query = "INSERT INTO `{$tableName}` SET `created`=1, `familiarity`={$familiarityUp}, `last_modified`=NOW(), `last_accessed`=NOW(), `first_accessed`=NOW(), `object_id`='{$objectId}', `model`='{$objectModel}', `user_id`='{$user}' ON DUPLICATE KEY UPDATE `modified`=`modified`+1, `familiarity`=`familiarity`+{$familiarityUp}, `session`='{$session}',  last_modified=NOW();";
        $command = Yii::$app->db->createCommand($query);

        return $command->execute();
    }
public static function created($object, $user = null)
    {
        $objectId = $object->id;
        $objectModel = addslashes($object->modelAlias);
        if (is_null($user) and isset(Yii::$app->user)) {
            $user = Yii::$app->user->id;
        }
        if (is_object($user)) {
            $user = $user->primaryKey;
        }
        if (empty($user) or empty(Yii::$app->session)) {
            return false;
        }
        $session = Yii::$app->session->id;

        $tableName = self::tableName();
        $familiarityUp = self::CREATED_FAMILIARITY;
        $query = "INSERT INTO `{$tableName}` SET `created`=1, `familiarity`={$familiarityUp}, `last_modified`=NOW(), `last_accessed`=NOW(), `first_accessed`=NOW(), `object_id`='{$objectId}', `model`='{$objectModel}', `user_id`='{$user}' ON DUPLICATE KEY UPDATE `modified`=`modified`+1, `familiarity`=`familiarity`+{$familiarityUp}, `session`='{$session}',  last_modified=NOW();";
        $command = Yii::$app->db->createCommand($query);

        return $command->execute();
    }
[[@doctodo method_description:created]].

@param unknown $object
@param unknown $user   (optional)

@return unknown