Skip to content

Update insert-data example to fix errors #466

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ The `DatabaseQuery` class provides a number of methods for building insert queri
the most common being insert, columns and values.

```php
// Define the variables passed to the bind function.
$user_id = 1001;
$profile_key = 'custom.message';
$profile_value = 'Inserting a record using insert()';
$ordering = 1;

// Get a db connection.
$db = Factory::getContainer()->get('DatabaseDriver');

Expand All @@ -68,10 +74,10 @@ $query

// Bind values
$query
->bind(':user_id', 1001, Joomla\Database\ParameterType::INTEGER)
->bind(':profile_key', 'custom.message')
->bind(':profile_value', 'Inserting a record using insert()')
->bind(':ordering', 1, Joomla\Database\ParameterType::INTEGER);
->bind(':user_id', $user_id, \Joomla\Database\ParameterType::INTEGER)
->bind(':profile_key', $profile_key)
->bind(':profile_value', $profile_value)
->bind(':ordering', $ordering, \Joomla\Database\ParameterType::INTEGER);

// Set the query using our newly populated query object and execute it.
$db->setQuery($query);
Expand Down