sql concat()関数解釈

1128 ワード

2つのフィールドを直列に接続するために使用します
typesテーブル
id     name  pid  path      
12男装0 0,13女装0,14ネクタイ12,12,15スーツ12,12,
eg:
 $sql = select types.*,concat(path,id) p from types order by p ;
$data = $sql->exec();
echo "
"; 
  

print_r($data);


Array
(
    [0] => stdClass Object
        (
            [id] => 12
            [name] =>   
            [pid] => 0
            [path] => 0,
            [p] => 0,12
        )

    [1] => stdClass Object
        (
            [id] => 14
            [name] =>   
            [pid] => 12
            [path] => 0,12,
            [p] => 0,12,14
        )


    [3] => stdClass Object
        (
            [id] => 15
            [name] =>   
            [pid] => 12
            [path] => 0,12,
            [p] => 0,12,15
        )

    [4] => stdClass Object
        (
            [id] => 13
            [name] =>   
            [pid] => 0
            [path] => 0,
            [p] => 0,13
        )
)