Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

help with "replace into" #23

Open
andaroid opened this issue Mar 5, 2024 · 0 comments
Open

help with "replace into" #23

andaroid opened this issue Mar 5, 2024 · 0 comments

Comments

@andaroid
Copy link

andaroid commented Mar 5, 2024

how to use replace into with initPHP\Database library ?

example

$data = array(
    array('id' => 1, 'name' => 'John'),
    array('id' => 2, 'name' => 'Jane'),
    // Add more data as needed
);

// Prepare the SQL statement
$sql = "REPLACE INTO your_table (id, name) VALUES (:id, :name)";

// Prepare the PDO statement
$stmt = $pdo->prepare($sql);

// Iterate through the data and execute the statement for each set of values
foreach ($data as $row) {
    try {
        $stmt->execute($row);
        // Handle success or log if needed
    } catch (PDOException $e) {
        // Handle error or log if needed
        echo "Error: " . $e->getMessage();
    }
}

I see you have updated your library and many files have been removed!!
If I update the library in my project will there be any problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant