×
Please submit new Bug Reports on GitHub: github.com/Jensen-Technologies/component-creator-issues/issues
Problem SQL - Field
Xze Rod
New Member
Posts: 7
10 năm 3 tháng trước - 10 năm 3 tháng trước #309
bởi Xze Rod
Problem SQL - Field was created by Xze Rod
Hi,
what code do i have to fill into the query field to get a list of a costum database?
In other custom-php's i used a query like:
translated to joomla query this should be:
but i got some error rmessages in front & backend. Meanwhile, i changed the componentname.php in both 'models' folders of site & administration to get this component work. Without those sql-queries, the component works fine.
In my next step, i changed the codelines of the componentname.php to:
[...]as far as i know, the $query should work, but in front & backend, i get the strange error-message:
Fatal error: Call to a member function select() on a non-object in [...]/administrator/components/com_jgames/models/matchlisten.php on line 198
Fatal error: Call to a member function select() on a non-object in /components/com_jgames/models/matchlisten.php on line 163
The Codeline in both cases is :
can somebody help me
what code do i have to fill into the query field to get a list of a costum database?
In other custom-php's i used a query like:
$query = "
SELECT `id`, `name`
FROM `#__vereine`
ORDER BY `id`;
";
$db->setQuery($query);
$data = $db->loadObjectList();
translated to joomla query this should be:
$query
->select($db->quoteName('id', 'name'))
->from($db->quoteName('#__jclubs'))
->order('id ASC');
$db->setQuery($query);
$results = $db->loadObject();
but i got some error rmessages in front & backend. Meanwhile, i changed the componentname.php in both 'models' folders of site & administration to get this component work. Without those sql-queries, the component works fine.
In my next step, i changed the codelines of the componentname.php to:
[...]
public function getItems() {
$items = parent::getItems();
foreach ($items as $oneItem) {
$oneItem->art = JText::_('COM_JGAMES_MATCHLISTEN_ART_OPTION_' . strtoupper($oneItem->art));
$oneItem->abteilung = JText::_('COM_JGAMES_MATCHLISTEN_ABTEILUNG_OPTION_' . strtoupper($oneItem->abteilung));
if (isset($oneItem->heimverein)) {
$values = explode(',', $oneItem->heimverein);
$textValue = array();
foreach ($values as $value){
if(!empty($value)){
$db = JFactory::getDbo();
$query
->select($db->quoteName('id', 'name'))
->from($db->quoteName('#__jclubs'))
->order('id ASC');
$db->setQuery($query);
$results = $db->loadObject();
if ($results) {
$textValue[] = $results->value;
}
}
}
$oneItem->heimverein = !empty($textValue) ? implode(', ', $textValue) : $oneItem->heimverein;
}
if (isset($oneItem->gastverein)) {
$values = explode(',', $oneItem->gastverein);
$textValue = array();
foreach ($values as $value){
if(!empty($value)){
$db = JFactory::getDbo();
$query
->select($db->quoteName('id', 'name'))
->from($db->quoteName('#__jclubs'))
->order('id ASC');
$db->setQuery($query);
$results = $db->loadObject();
if ($results) {
$textValue[] = $results->value;
}
}
}
$oneItem->gastverein = !empty($textValue) ? implode(', ', $textValue) : $oneItem->gastverein;
}
$oneItem->heimabteilung =
JText::_('COM_JGAMES_MATCHLISTEN_HEIMABTEILUNG_OPTION_' .
strtoupper($oneItem->heimabteilung));
$oneItem->gastabteilung =
JText::_('COM_JGAMES_MATCHLISTEN_GASTABTEILUNG_OPTION_' .
strtoupper($oneItem->gastabteilung));
$oneItem->heimmannschaft =
JText::_('COM_JGAMES_MATCHLISTEN_HEIMMANNSCHAFT_OPTION_' .
strtoupper($oneItem->heimmannschaft));
$oneItem->gastmannschaft =
JText::_('COM_JGAMES_MATCHLISTEN_GASTMANNSCHAFT_OPTION_' .
strtoupper($oneItem->gastmannschaft));
}
return $items;
}
[...]
Fatal error: Call to a member function select() on a non-object in [...]/administrator/components/com_jgames/models/matchlisten.php on line 198
Fatal error: Call to a member function select() on a non-object in /components/com_jgames/models/matchlisten.php on line 163
The Codeline in both cases is :
->select($db->quoteName('id', 'name'))
can somebody help me
Last edit: 10 năm 3 tháng trước by Xze Rod.
Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.
Xze Rod
New Member
Posts: 7
10 năm 3 tháng trước #310
bởi Xze Rod
Replied by Xze Rod on topic Problem SQL - Field
ok, solved this problem after testing some query-changes
thanks - really nice tool
thanks - really nice tool
Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.
Andres Maeso
Platinum Member
Posts: 338
10 năm 3 tháng trước #311
bởi Andres Maeso
Andrés Maeso
Customer relations manager at Joomla Component Creator.
This email address is being protected from spambots. You need JavaScript enabled to view it.
Replied by Andres Maeso on topic Problem SQL - Field
Glad you could make it on your own! Is there a chance to share the solution with the rest of the community?
Andrés Maeso
Customer relations manager at Joomla Component Creator.
This email address is being protected from spambots. You need JavaScript enabled to view it.
Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.
Xze Rod
New Member
Posts: 7
10 năm 3 tháng trước #317
bởi Xze Rod
Replied by Xze Rod on topic Problem SQL - Field
Yes, of course
let's say, this is the sql query i want to use
-> i have to insert only these code-lines into the query-field
let's say, this is the sql query i want to use
$query
->select($db->quoteName('id', 'name'))
->from($db->quoteName('#__jclubs'));
$db->setQuery($query);
$results = $db->loadObject();
SELECT `id`, `name`
FROM `#__clubs`
Những thành viên sau(s) đã Cảm ơn: Andres Maeso
Vui lòng Đăng nhập hoặc Tạo tài khoản để tham gia cuộc hội thoại.
Thời gian tải trang: 0.079 giây