Error while using fulltext filed of jos_content table in query inside JModel

114 views
Skip to first unread message

Zubair Hussain

unread,
Apr 18, 2012, 6:34:11 AM4/18/12
to joomla-...@googlegroups.com
When I use   id, fulltext as fields in query select statement(
select("id,fulltex")
I got following error message


Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\25\components\com_test\views\article_list\tmpl\default.php on line 2



 however if i use * in that case my component runs fines. 
 what could be possible reason.

class TestModelArticle_list extends JModel
{
public function getList()
{
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->select("*"); // works fine... But If I write like 
$query->select("id,fulltext") it produce error
$query->from("#__content");
$db->setQuery($query);
$rows= $db->loadObjectList(); 
return ($rows);
}


Regards

Zubair Hussain


djanu...@gmail.com

unread,
Apr 18, 2012, 6:40:00 AM4/18/12
to Joomla! CMS Development
Hi

FULLTEXT being a keyword in MySQL, when using it as a field name you
must quote it with backticks `fulltext` is correct.

Dhanam Asirvatham

unread,
Apr 18, 2012, 11:06:24 AM4/18/12
to joomla-...@googlegroups.com
On Wed, Apr 18, 2012 at 4:04 PM, Zubair Hussain <zub...@vuzs.net> wrote:
When I use   id, fulltext as fields in query select statement(
select("id,fulltex")
I got following error message


Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\25\components\com_test\views\article_list\tmpl\default.php on line 2



 however if i use * in that case my component runs fines. 
 what could be possible reason.

class TestModelArticle_list extends JModel
{
public function getList()
{
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->select("*"); // works fine... But If I write like 
$query->select("id,fulltext") it produce error
   $query->select(array('id','fulltext')); // try this
$query->from("#__content");
$db->setQuery($query);
$rows= $db->loadObjectList(); 
return ($rows);
}


Regards

Zubair Hussain


--
You received this message because you are subscribed to the Google Groups "Joomla! CMS Development" group.
To post to this group, send an email to joomla-...@googlegroups.com.
To unsubscribe from this group, send email to joomla-dev-cm...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/joomla-dev-cms?hl=en-GB.



--
A. Dhanapal
http://www.tutyonline.com

Mark Dexter

unread,
Apr 19, 2012, 2:41:42 PM4/19/12
to joomla-...@googlegroups.com
What is on line 2 of
components\com_test\views\article_list\tmpl\default.php? Mark

Thierry bela nanga

unread,
Apr 19, 2012, 2:52:19 PM4/19/12
to joomla-...@googlegroups.com
fulltext is a reserved MySQL keyword, you should use

select("id,".$db->nameQuote('fulltext')) instead
http://tbela99.blogspot.com/

fax : (+33) 08 26 51 94 51

Zubair Hussain

unread,
Apr 21, 2012, 2:27:49 AM4/21/12
to joomla-...@googlegroups.com
Thierry blea nanga thank you,  its working perfectly.

@ Mark Dexter

I had the following line 

foreach ($this->articleContent as $row):

Regards

Zubair Hussain
Reply all
Reply to author
Forward
0 new messages