<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Question2Answer Q&amp;A - Recent questions tagged substitution</title>
<link>https://www.question2answer.org/qa/tag/substitution</link>
<description>Powered by Question2Answer</description>
<item>
<title>parameter substitution incomplete when trying to override qa_db_posts_basic_selectspec</title>
<link>https://www.question2answer.org/qa/35733/substitution-incomplete-qa_db_posts_basic_selectspec</link>
<description>

&lt;p&gt;
	I am trying to override the above function to additionally filter for some information stored in postmetas.&lt;/p&gt;


&lt;p&gt;
	I made a copy of the original function and added the following items to source and arguments, immediately after the initial set-up of the $selectspec array.&lt;/p&gt;


&lt;blockquote&gt;
	

&lt;p&gt;
		&lt;span style=&quot;font-family:courier new,courier,monospace;&quot;&gt;$selectspec['source'].=' LEFT JOIN ^postmetas ON ^postmetas.postid = ^posts.postid AND ^postmetas.title=\'custField\' AND ^postmetas.content=$';
&lt;br&gt;
		array_push($selectspec['arguments'],$custValue);&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;p&gt;
	The query now throws an error because postid is not filled in in the generated query, even though my addtion to the code has nothing to with postids and the part I added comes out correctly formed.&lt;/p&gt;


&lt;p&gt;
	The generated queries contain sequences like:&lt;/p&gt;


&lt;blockquote&gt;
	

&lt;p&gt;
		&lt;span style=&quot;font-family:courier new,courier,monospace;&quot;&gt;...WHERE qa_posts.postid=(SELECT IF(LEFT(parent.type, 1)='A', parent.parentid, parent.postid) FROM qa_posts AS child LEFT JOIN qa_posts AS parent ON parent.postid=child.parentid WHERE child.postid=#)&lt;/span&gt;&lt;/p&gt;
	

&lt;p&gt;
		&lt;span style=&quot;font-family:courier new,courier,monospace;&quot;&gt;...WHERE qa_posts.postid=(SELECT closedbyid FROM qa_posts WHERE postid=#)&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;p&gt;
	Please Note:&lt;/p&gt;


&lt;p&gt;
	The code works correctly when I comment out my added lines.&lt;/p&gt;


&lt;p&gt;
	When listing all questions in the main view, there is no error (maybe this is handled by a different function), the problem only occurs when trying to view the details of a question.&lt;/p&gt;


&lt;p&gt;
	&amp;nbsp;&lt;/p&gt;


&lt;p&gt;
	&lt;span style=&quot;text-decoration: underline;&quot;&gt;UPDATE:&lt;/span&gt;&lt;/p&gt;


&lt;p&gt;
	I tried to insert my argument into the 'source' string instead of array_pushing onto 'arguments' and now the error is gone.&lt;/p&gt;


&lt;blockquote&gt;
	

&lt;p&gt;
		&lt;span style=&quot;font-family:courier new,courier,monospace;&quot;&gt;$selectspec['source'].=' LEFT JOIN ^postmetas ON ^postmetas.postid = ^posts.postid AND ^postmetas.title=\'custField\' AND ^postmetas.content=\''.$custValue.'\'';&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;p&gt;
	So I must be doing something wrong when pushing onto the 'arguments' array ... but what?&lt;/p&gt;</description>
<category>Q2A Core</category>
<guid isPermaLink="true">https://www.question2answer.org/qa/35733/substitution-incomplete-qa_db_posts_basic_selectspec</guid>
<pubDate>Mon, 07 Jul 2014 05:59:17 +0000</pubDate>
</item>
</channel>
</rss>