如何執行自定義MySQL查詢以從Zoo數據庫表中獲取記錄?執行mysql查詢從動物園組件動物園版本3表中獲取記錄
沿此查詢的東西線:
SELECT "64ccc68f-4af3-4c02-8c0f-8ec5977bacb2"
FROM #__zoo_item
WHERE application_id=1 and state=1 and type='handy'
如何執行自定義MySQL查詢以從Zoo數據庫表中獲取記錄?執行mysql查詢從動物園組件動物園版本3表中獲取記錄
沿此查詢的東西線:
SELECT "64ccc68f-4af3-4c02-8c0f-8ec5977bacb2"
FROM #__zoo_item
WHERE application_id=1 and state=1 and type='handy'
// Get a db connection.
$db = JFactory::getDbo();
// Create a new query object.
$query = $db->getQuery(true);
// Select all records from the user profile table where key begins with "custom.".
// Order it by the ordering field.
$query->select($db->quoteName(array('user_id', 'profile_key', 'profile_value', 'ordering')));
$query->from($db->quoteName('#__user_profiles'));
$query->where($db->quoteName('profile_key') . ' LIKE '. $db->quote('\'custom.%\''));
$query->order('ordering ASC');
// 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).
$results = $db->loadObjectList();
根據你在你的問題發佈查詢,以下將是的Joomla相當於:
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('64ccc68f-4af3-4c02-8c0f-8ec5977bacb2')))
->from($db->quoteName('#__zoo_item'))
->where($db->quoteName('application_id') . ' = 1 AND '.
$db->quoteName('state') . ' = 1 AND '.
$db->quoteName('type') . ' = ' $db->quoteName('handy'));
$db->setQuery($query);
$results = $db->loadObjectList();
$results
是查詢結果的一個對象,您可以隨後執行任何您想要的操作。
希望這可以幫助
你可以很容易地使用動物園API獲得你想要的東西。我必須說他們有最好的API來獲取API。使用項目讓你可以獲得動物園記錄的所有信息,你只需要將動物園項目ID傳遞給函數。
$app = App::getInstance('zoo');
$item = $app->table->item->get($ITEM_ID); // Zoo Record Id
$Element_Id = "64ccc68f-4af3-4c02-8c0f-8ec5977bacb2"; // One of the text field element id
$element_value = $item->getElement($Element_Id)->getElementData()->get('value');
// $element_value contains the actual value of element id $Element_Id of item id $ITEM_ID.
閱讀此博客閱讀更多。 http://atpatil.blogspot.in/2013/04/access-zoo-element-data-anywhere-in.html
你讀過關於編寫數據庫查詢的Joomla文檔嗎? – Lodder 2014-10-09 11:39:51
我問野兔獲得 「元素」 一欄,這列有這樣{ \t \t 「f04e712e-b17d-4421-83cd-291a7cdd5b6e」 JSON值:{ \t \t 「選項」:{ \t \t \t「 0" : 「videoaufzeichnung」 \t \t} \t}, \t 「8a473b51-7682-4fcd-AC58-c57a35b610dc」:{ \t \t 「0」:{ \t \t \t 「值」:「2梅格apixel」 \t \t} \t}, \t 「b203f386-ed38-43f3-b9e8-211ee720c31b」:{ \t \t 「0」:{ \t \t \t 「值」: 「」 \t \t} \t} , \t 「52f5424f-1776-4011-97bc-918159221fd6」:{ \t \t 「0」:{ \t \t \t 「值」: 「15」 \t \t} \t}, \t 「9231e9f5-67d0-4147-9eb9-2c832205e19b」:{ \t \t 「0」:{ \t \t \t 「值」: 「4倍」 \t \t} \t} \t } – 2014-10-09 12:11:49
請閱讀下面的答案並研究數據庫查詢的Joomla文檔。今後,請更具體地瞭解您的要求,以便我們不浪費時間編寫您不需要的代碼 – Lodder 2014-10-09 12:17:04