gpt4 book ai didi

php - Mysql两列使用PHP在Rows中查找一条数据

转载 作者:行者123 更新时间:2023-11-29 15:23:51 24 4
gpt4 key购买 nike

我必须尝试两次连接,但这行不通。Codeginator 中的代码。

$this->db->select('concat(firstName," ",lastName) as fullnameVisitor,users.firstName,visitorId,destinationId,count,activityStatus,created,updated');
$this->db->from('interestedprofile');
$this->db->join('users','users.userId=interestedprofile.visitorId','LEFT');
$this->db->join('users','users.userId=interestedprofile.destinationId','LEFT');
$this->db->join('interestedprofile','interestedprofile.destinationId=users.userId','LEFT');
$this->db->order_by('created','desc');
return $this->db->get()->result_array();

用户表: /image/ppM3s.png兴趣表: /image/EbQIX.png

我必须在用户表中找到visitedid和destinationid用户的firstName和lastName。

最佳答案

您不必完全使用 Active Record 来进行连接。您可以使用常规 SQL。例如,

$query = $db->query("SELECT * FROM users;");

foreach ($query->getResult('User') as $user)
{
echo $user->name; // access attributes
echo $user->reverseName(); // or methods defined on the 'User' class
}

关于php - Mysql两列使用PHP在Rows中查找一条数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59180473/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com