php - trying to create a 'join' statement using Zend DB Table - zend framework 2
Get the solution ↓↓↓Solution:
Try changing your Zend_Db_Select object to the following:
$select = $this->select()
->join($accountsTable, 'friend_list.friend_id = user_profile.id', array())
->where('user_profile.id = ?', $userID)
->reset('columns')
->columns(array('friend_list.friend_id', 'user_profile.id', 'user_profile.username'));
Answer
Solution:
This is not an answer to the question but since i cant comment yet i will post this here. I found the following website helpful with the join examples.
Answer
Solution:
the end result of my model_friends script is as follows:
<?php
//model created to add user to database, sendmail etc...
require_once 'Zend/Db/Table/Abstract.php';
class Model_Friends extends Zend_Db_Table_Abstract
{
protected $_name = "friend_list";
public function fetchFriendList($userID)
{
$select = $this->select()
->from($this)
->setIntegrityCheck(false)
->join(array('u'=>'user_profile'), 'friend_list.friend_id =u.id', array())
->columns(array('u.id', 'u.username'))
->where("friend_list.user_id = ?", $userID);
$result = $this->fetchAll($select);
if ($result !== null){
echo $select;
return $result;
} else {
echo "no records found";
}
}
}
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: the browser (or proxy) sent a request that this server could not understand.
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.