在此处遵循本教程:http: //docs.joomla.org/Selecting_data_using_JDatabase#Selecting_Records_from_a_Single_Table
我创建了一个函数,如下所示:
function getItemForBid() {
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select item record matching the $orderID
$query
->select($db->quoteName(array('id', 'created_by', 'itemtitle', 'deliverydestination', 'listprice')))
->from($db->quoteName('#__entrusters_items'))
->where('id = '.$_GET['orderID']);
// Reset the query using our newly populated query object.
$db->setQuery($query);
// Load the results as a list of stdClass objects (see later for more options on retrieving data).
$db->setQuery($query);
$bidItem = $db->loadObject();
//print_r($bidItem);
}
print_r($bidItem);
作品和回报,例如:
stdClass Object (
[id] => 4
[created_by] => 216
[itemtitle] => Tennis Racket
[deliverydestination] => London
[listprice] => 5000
)
但是,如果我尝试在页面上的其他位置回显其中一个值,例如:
<input name="jform[item_id]" id="jform_item_id" value="<?php echo $bidItem->id; ?> " readonly="" type="text">
我什么都得不到。该手册说您可以使用以下方法访问各个值:
$result->index // e.g. $result->email
我在做一些非常愚蠢的事情吗?