D
D
des1roer2015-08-18 08:05:15
Yii
des1roer, 2015-08-18 08:05:15

Yii 1.* Recursive query in dropDownList?

How can I screw in a request like

WITH RECURSIVE temp1 ( p_id,p_parent,p_title,PATH, LEVEL, NAME  ) AS (
SELECT T1.p_id,T1.p_parent, T1.p_title, 
CAST (T1.p_id AS VARCHAR (50)) as PATH, 1 , 
CAST (T1.p_title AS VARCHAR (255)) as NAME
    FROM "SC_Wonder".t_page T1 WHERE T1.p_parent = 0
union
select T2.p_id, T2.p_parent, T2.p_title, 
CAST ( temp1.PATH ||'->'|| T2.p_id AS VARCHAR(50)) ,LEVEL + 1 ,
CAST ((repeat('  ', LEVEL+1)||T2.p_title) AS VARCHAR(255))
     FROM "SC_Wonder".t_page T2 INNER JOIN temp1 ON( temp1.p_id= T2.p_parent))
select * from temp1 ORDER BY PATH LIMIT 100

in dropDownList
<?php
///список отделов из t_department
$opts = CHtml::listData(Department::model()->findAll('id_parent =5'), 'id', 'name');
?>
<hr />
<div class="column">  
    <?php
    $arr_bit[] = 5; //пункт по умолчанию 
    echo $form->dropDownList($model, 'level_id', $opts, $arr_bit, array
       (
            'empty' => Yii::t('default', 'выберите горизонт'),
        )
    );
    ?>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question