ThingEngineer / PHP-MySQLi-Database-Class

Wrapper for a PHP MySQL class, which utilizes MySQLi and prepared statements.
Other
3.29k stars 1.35k forks source link

Wrong Operation #940

Closed Vukajlovic closed 3 years ago

Vukajlovic commented 3 years ago

image

I'm using this class for couple of months. I just got this error. I was searching on google if someone has same problem but no use.

Anyway this is my code sample

             `$prepareData  = array(
        'mb_username'      => $username,
        'mb_password'      => $password,
        'mb_email'         => $email,
        'mb_last_seen'     => 0,
        'mb_is_verified'   => 0,
        'mb_is_admin'      => 0,
        'mb_is_banned'     => 0,
        'mb_is_restricted' => 0,
        'mb_balance'       => 0,
        'mb_is_premium'    => 0,
        'mb_premium_type'  => 0,
    );

    $registerUser = $this->connection->insert('tbl_members', $prepareData);
    if(!$registerUser){
        return array(
            'status' => 400,
            'reason' => 'We were unable to register you right now. Please try again soon !',
            'errorCode' => '1aaaa4'
        );
    }
    $prepareData = array(
        'reg_id'                => $registerUser,
        'reg_registration_time' => $this->DateTimeReturn(0, 1),
        'reg_client_info'       => $browser_data,
        'reg_registered_ip'     => $ip_address,
    );

    $registrationInfo = $this->connection->insert('tbl_registration_info', $prepareData);
    if(!$registrationInfo){
        $this->connection->where('mb_uid', $registerUser);
        $this->connection->delete('tbl_members');
        $this->connection->rawQuery("ALTER TABLE `tbl_members` AUTO_INCREMENT = ?", array($registerUser));
        return array(
            'status'    => 400,
            'reason'    => 'We were unable to register you right now. Please try again soon !',
            'errorCode' => '1aaaa5'
        );
    }
    $verificationKey = md5(md5($insertSQL) . microtime() . uniqid());

    $prepareData = array(
        'ver_id'                => $registerUser,
        'ver_verification_key'  => $verificationKey,
        'ver_time'              => $this->DateTimeReturn(0, 1),
    );

    $verificationInsert = $this->connection->insert('tbl_verification_keys', $prepareData);
    if(!$verificationInsert){
        $this->connection->where('reg_id', $registrationInfo);
        $this->connection->delete('tbl_registration_info');
        $this->connection->rawQuery("ALTER TABLE `tbl_members` AUTO_INCREMENT = ?", array($registrationInfo));

        $this->connection->where('mb_uid', $registerUser);
        $this->connection->delete('tbl_members');
        $this->connection->rawQuery("ALTER TABLE `tbl_members` AUTO_INCREMENT = ?", array($registerUser));

        return array(
            'status'    => 400,
            'reason'    => 'We were unable to register you right now. Please try again soon !',
            'errorCode' => '1aaaa6'
        );
    }`