Note that there are some explanatory texts on larger screens.

plurals
  1. POYii:Framework - Finding table with multiple related categories from $_POST
    primarykey
    data
    text
    <p>I use this Yii code in my controller to search after POST </p> <pre><code>$model = Questions::model()-&gt;with( array( 'categories' =&gt; array ( 'select' =&gt; 'name', 'condition' =&gt; 'categories.id=:cat_id', 'params' =&gt; array (':cat_id' =&gt; $_POST["Questions"]["categories"]) ), 'countries' =&gt; array ( 'select' =&gt; 'name', 'condition' =&gt; 'countries.id=:cou_id', 'params' =&gt; array (':cou_id' =&gt; $_POST["Questions"]["countries"]) ) ) )-&gt;findAll(array('select' =&gt; 'question')); </code></pre> <p>This is ok until all data in POST is not an array. </p> <p>I want to change POST to return an array. Now, when I return from view a $_POST['Questions']['categories'] as an array how do I write the criteria for Questions::model(). </p> <p>I get Notice: </p> <pre><code>Array to string conversion: this-&gt;_statement-&gt;bindValue($name, $value, $this-&gt;_connection-&gt;getPdoType(gettype($value))); </code></pre> <p>So, what is a correct way to do it ? :) </p> <p>-- The code for the post ( from the view ) </p> <pre><code>CHtml::activeCheckboxList($model, 'countries'CHtml::listData(Countries::model()-&gt;findAll(), 'id', 'name'), array('template'=&gt;'&lt;li&gt;{input} {label}&lt;/li&gt;',)); $form-&gt;dropDownList($model, 'categories', CHtml::listData(Categories::model()-&gt;findAll(), 'id', 'name'), array('prompt' =&gt; 'Select category') ); </code></pre> <p>if u need more info there is also my previous post, this is a continuation <a href="https://stackoverflow.com/questions/18764882/yii-framework-help-to-translate-relational-sql-query">see post</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload