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

Prepared Query Update problem #904

Closed
byazrail opened this issue Jan 14, 2018 · 2 comments
Closed

Prepared Query Update problem #904

byazrail opened this issue Jan 14, 2018 · 2 comments

Comments

@byazrail
Copy link
Contributor

Hi guys,
have a problem prepared queries on update binds.
I use postgresql

// core/Database/Query -> setQuery() result
echo debug($this->originalQueryString);

UPDATE user_profile SET deleted_id = :deleted_id, delete_date = :delete_date, status = :status
WHERE user_id = :user_id:
1
1

Last / core/Database/Postgre/PreparedQuery -> _prepare() result
$sql var_dump result
1

get results not problem;

$binds = [];
$binds[':deleted_id'] = null;
$binds[':user_id'] = 2;
$binds[':status'] = 1;
$binds[':delete_date'] = null;

$query = $this->db->prepare(function($db)
{
return $db->table('user_profile', false)
->set('deleted_id', ':deleted_id', false)
->set('delete_date', ':delete_date', false)
->set('status', ':status', false)
->where('user_id', ':user_id', false)
->update();
});

$query->execute($binds);

@JakeAi
Copy link
Contributor

JakeAi commented Jan 31, 2018

@byazrail Try this first. :bind:
https://bcit-ci.github.io/CodeIgniter4/database/queries.html?highlight=bind#named-bindings

UPDATE user_profile SET deleted_id = :deleted_id:, delete_date = :delete_date:, status = :status:
WHERE user_id = :user_id:

@lonnieezell
Copy link
Member

What @JakeAi said. Binds in recent times have used a colon both before and after the variable.

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

3 participants