UnPace
V2EX  ›  问与答

PHP 联表查询怎么写?

  •  
  •   UnPace · Oct 27, 2016 · 1390 views
    This topic created in 3486 days ago, the information mentioned may be changed or developed.

    目前在 Discuz!中有这样一段代码:

    $article['related'] = array(); if(($relateds = C::t('portal_article_related')->fetch_all_by_aid($aid))) { foreach(C::t('portal_article_title')->fetch_all(array_keys($relateds)) as $raid => $value) { $value['uri'] = fetch_article_url($value); $article['related'][$raid] = $value; }

    }

    它的作用是在添加相关文章后,在 portal_article_related 表里生成 ID 对应记录,然后通过 ID 获取到 portal_article_title 表中的相关字段,现在我想在此基础上,还需要通过 portal_article_title 表中的 catid 获得 portal_category 表里的相关记录,请问怎么写?

    谢谢。

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1043 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 18:38 · PVG 02:38 · LAX 11:38 · JFK 14:38
    ♥ Do have faith in what you're doing.