V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
UnPace
V2EX  ›  问与答

PHP 联表查询怎么写?

  •  
  •   UnPace · Oct 27, 2016 · 1365 views
    This topic created in 3468 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   ·   5238 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 01:16 · PVG 09:16 · LAX 18:16 · JFK 21:16
    ♥ Do have faith in what you're doing.