"PHP" / Говнокод #429 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
$path = "a/b/c/d";
$sections = array_reverse (explode ("/", $path));
$sql = "SELECT `t1`.`id` FROM ";
for ($i = 1; $i <= count ($sections); $i ++)
  $from_tables[] = "`test` `t".$i."`";
$sql = $sql.implode (", ", $from_tables);
$sql .= " WHERE ";
for ($i = 1; $i < count ($sections); $i ++)
  $sql .= "`t".$i."`.`parent_id` = `t".($i+1)."`.`id` AND `t".$i."`.`name` = '".$sections[$i-1]."' AND";
$sql .= " `t".count ($sections)."`.`parent_id` = '0' AND `t".count ($sections)."`.`name` = '".$sections[count($sections)-1]."'";
echo $sql;

Запостил: guest guest, (Updated )

Комментарии (1) RSS

Добавить комментарий

Из-за тебя ушел bormand, guest!

    А не использовать ли нам bbcode?


    8