Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

[SOLVED] WHERE Query 14 Jun 2013 13:19 #7473

Can a WHERE query be added in Cook, I can see the group by that works ok on a foreign field

I can grab a parameter from the url ok because I can echo it out, how do I

select * from table name where category = $categoryid

I have tried adding WHERE `vs4go_constructionprojects_projects.category` = `2` to the default query buildQueryWhere() section

function _buildQuery_default()
{

$query = ' SELECT a.*'
. ' , _category_.category AS `_category_category`'

. $this->_buildQuerySelect()

. ' FROM `vs4go_constructionprojects_projects` AS a '
. ' LEFT JOIN `vs4go_constructionprojects_categories` AS _category_ ON _category_.id = a.category'

. $this->_buildQueryJoin() . ' '

. $this->_buildQueryWhere()
. ' WHERE `vs4go_constructionprojects_projects.category` = `2` '

Please Log in or Create an account to join the conversation.

Last edit: by uglykidjoe.

Re: WHERE Query 15 Jun 2013 08:13 #7474

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
This part is now totally deprecated in 2.5 (actually, even since 2.0)

The source you are showing is very old.
The model has changed and the new way is much easier.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Re: WHERE Query 15 Jun 2013 08:51 #7476

  • etc
  • etc's Avatar
  • Offline
  • Premium Member
  • Premium Member
  • Posts: 132
  • Thank you received: 19
Try this old fashioned way:
. $this->addWhere('`category` = 2')

Please Log in or Create an account to join the conversation.

Re: WHERE Query 17 Jun 2013 05:48 #7502

admin wrote: This part is now totally deprecated in 2.5 (actually, even since 2.0)

The source you are showing is very old.
The model has changed and the new way is much easier.


Not really sure what you mean as the code has been generated by Cook (apart from my bit)

Anyway I got it to work by adding to the where function, so my where function looks like this
function _buildQueryWhere($where = array())
{
$app = JFactory::getApplication();
$db= JFactory::getDBO();
$acl = ConstructionprojectsHelper::getAcl();
$categoryid = JRequest::getVar('categoryid');



if (isset($this->_active['filter']) && $this->_active['filter'])
{
$filter_category = $this->getState('filter.category');
if ($filter_category != '') $where[] = "a.category = " . (int)$filter_category . "";


}
if (!$acl->get('core.edit.state')
&& (!isset($this->_active['publish']) || $this->_active['publish'] !== false))
$where[] = "a.published=1";

if ($categoryid != '') $where[] = "a.category= " .$categoryid."";

return parent::_buildQueryWhere($where);
}

Steve
The following user(s) said Thank You: admin

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.089 seconds

  I found "cook" two days ago. Played around with it for a day and then within a day got rid of two legacy applications in IBM Lotus Domino Notes and replaced them with "cook". It was really easy. A piece of cake. Actually it was even easier than cooking. Cooking involves more work than developing with "cook". What can I say about "cook"? Great application great price for what it delivers great forum with a lot of information and fast responses active and friendly community fast forward moving development cycle So what should I say "Monsieur Le Cook"? Keep the good work going it will lead to success. Having become a paying member in the words of Edith Piaf may I say ..... non rien de rien ... je ne regrette rien. Vive La France.
FK (JED)
         

Get Started