Double registration in the database?

0

I have already rolled my code and found the reason that it is adding two records in the database.

Function:

public static function create($table, array $params) {
    $key = array_keys($params);
    $value = array_values($params);

    $key = "'" . implode("', '", $key) . "'";
    $value = "'" . implode("', '", $value) . "'";

    $sql = "INSERT INTO '" . self::$_prefix . "{$table}' ({$key}) VALUES ({$value})";

    $pdo = self::get()->query($sql);
    $pdo->execute();
}

Function call:

Connect::create('users', array(
    'name' => 'Guilherme',
    'lastname' => 'Alsdfafdves',
    'email' => '[email protected]',
    'username' => 'caraiosssss',
    'password' => '123456',
));
    
asked by anonymous 20.02.2016 / 01:36

1 answer

1

I solved my error, since the self::get()->query(); function already does the job of executing, I only removed the $pdo->execute(); .

    
20.02.2016 / 01:56