05-27-2008, 08:39 AM
[eluser]rvent[/eluser]
Hello,
I am having this little problem that i cant seem to find a solution to. I am executing a query to my DB to get a single record once i get it it is used by another function to get the list of records who belong to that value.
EX: I have a workOrder 12345 and workOrder 12345 has many messages all of which have an association to their respective workOrder.
Here is my model function:
And here is my test controller function:
ANd certainly this is a no go since i get error about object properties:
the docs say that using "query->" i would need to use the http://ellislab.com/codeigniter/user-gui...sults.html but i feel like using a whole block to get 1 result its a little too much..
Is there another way to get a single result other than:
Thanks..
Hello,
I am having this little problem that i cant seem to find a solution to. I am executing a query to my DB to get a single record once i get it it is used by another function to get the list of records who belong to that value.
EX: I have a workOrder 12345 and workOrder 12345 has many messages all of which have an association to their respective workOrder.
Here is my model function:
Code:
function getWOid($woID)
{
$sqlGetWo = "SELECT WOrderID
FROM WorkOrder
WHERE WOrder = ?
LIMIT 1";
$sqlWoID = $this->db->query($sqlGetWo, array($woID));
return $sqlWoID;
}
And here is my test controller function:
Code:
function testDB()
{
$wId = $this->input->post('WorkOrder');
$messageID = NULL;
$woID = $this->SmtJob->getWOid($wId);
$row = $woID->row();
$myID = $row->WOrderID;
$messageData = array('WOMessage' => $this->input->post('Message'),
'WOMessageID' => $this->input->post('WOMessageID'),
'AuthorID' => $this->input->post('AuthorID'));
$msgData = array('WOMessage' => $this->input->post('Message'),
'WOMessageID' => $messageID,
'AuthorID' => $this->input->post('Author'),
'WOrderID' => $myID);
echo "$wId <br>";
echo $messageData['WOMessage'];
echo $msgData['WOrderID'];
}
ANd certainly this is a no go since i get error about object properties:
Code:
$woID = $this->SmtJob->getWOid($wId);
$row = $woID->row();
$myID = $row->WOrderID;
the docs say that using "query->" i would need to use the http://ellislab.com/codeigniter/user-gui...sults.html but i feel like using a whole block to get 1 result its a little too much..
Is there another way to get a single result other than:
Code:
$query = $this->db->query("YOUR QUERY");
foreach ($query->result() as $row)
{
echo $row->title;
echo $row->name;
echo $row->body;
}
Thanks..