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

getCompiledSelect() return query without binds #1526

Closed
nowackipawel opened this issue Nov 22, 2018 · 1 comment
Closed

getCompiledSelect() return query without binds #1526

nowackipawel opened this issue Nov 22, 2018 · 1 comment
Labels
database Issues or pull requests that affect the database layer

Comments

@nowackipawel
Copy link
Contributor

nowackipawel commented Nov 22, 2018

*alpha2.

Just close it if this is not an error :)
According to: https://codeigniter4.github.io/CodeIgniter4/database/query_builder.html I wrote:


				$db = \Config\Database::connect(DB_ZTO_GROUP);
				$builder = $db->table(self::$multiRelation[$relation_name]['table']);
				$builder
					->select($relation_name . '_' .self::$multiRelation[$relation_name][$as_rev?'to':'from'][0])
					->{$in_relation ? 'whereIn' : 'whereNotIn'}(
						$relation_name  . '_' . self::$multiRelation[$relation_name][$as_rev?'from':'to'][0],
						$values
					);

				d($builder->getCompiledSelect()); 

but d() prints:

SELECT `fcs2fct_fcs_identifier`
FROM `t_file_conversion_set2t_file_conversion_task`
WHERE `fcs2fct_fct_identifier` IN :fcs2fct_fct_identifier:

instead of:


SELECT `fcs2fct_fcs_identifier`
FROM `t_file_conversion_set2t_file_conversion_task`
WHERE `fcs2fct_fct_identifier` IN ('val1','val2')

I checked it and $values contains val1 and val2. Shouldn't getCompiledSelect returns sql with binded values? Docs : "Compiles the selection query just like $builder->get() but does not run the query. This method simply returns the SQL query as a string."

@lonnieezell
Copy link
Member

One would think that, but I believe that's old docblock from before the CI4 changes. However, the database layer isn't something that I know intimately. I did make the change to use query class, since that's needed to work with prepared queries, and makes everything a bit more streamlined. It may be that the naming of that class is no longer relevant. However, I do know the database layer works currently and I'm a bit leery of touching it just now. :)

@jim-parry jim-parry added the database Issues or pull requests that affect the database layer label Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database Issues or pull requests that affect the database layer
Projects
None yet
Development

No branches or pull requests

3 participants