Welcome, Guest
Username: Password: Remember me

TOPIC: Getting query's column names

Getting query's column names 02 Aug 2012 14:39 #2961

  • jroberge
  • jroberge's Avatar
  • Offline
  • Junior Member
  • Posts: 23
  • Karma: 0
Hello,

I am building an html table based on user request. The user is presented with all possible values with a list of checkboxes. The query is built based on checked values.

In order to show appropriate number of columns, I want to evaluate the presence of the column based on the column name. To do this in my first PHP development, I used to used the PHP function mysql_field_name(). How can I achieve something similar in Joomla!, especially in Cook?

Thanks,

José
The administrator has disabled public write access.

Re: Getting query's column names 05 Aug 2012 15:47 #3000

  • e-struct
  • e-struct's Avatar
  • Offline
  • Senior Member
  • Posts: 76
  • Thank you received: 4
  • Karma: 5
Maybe you have a look to:
http://docs.joomla.org/How_to_use_the_database_classes_in_your_script
Last Edit: 05 Aug 2012 15:48 by e-struct.
The administrator has disabled public write access.
The following user(s) said Thank You: admin

Re: Getting query's column names 05 Aug 2012 18:42 #3007

  • VeCrea
  • VeCrea's Avatar
  • Offline
  • Platinum Member
  • Absolute JCook fan
  • Posts: 473
  • Thank you received: 100
  • Karma: 30
Are you familiar with the MVC design pattern (sorry to ask, i just don't know what you already know or don't know so i can point you in the right direction) ?
The administrator has disabled public write access.

Re: Getting query's column names 06 Aug 2012 08:44 #3020

  • jroberge
  • jroberge's Avatar
  • Offline
  • Junior Member
  • Posts: 23
  • Karma: 0
veCrea, Yes, I am familiar with MVC (although it is not natural to me), and getting able to find my way in the code generated by Cook. I like the way everything is prepared with Cook and want to stay as close as possible with it. There is certainly a way to evaluate based on the third term of JHTML.
JHTML::_('grid.sort',  "SUIVIRM6_FIELD_STATUT", '_statutfiche_.statut', $this->lists['order_Dir'], $this->lists['order'])

Or is there a better way?

Thanks,
The administrator has disabled public write access.

Re: Getting query's column names 06 Aug 2012 11:32 #3029

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
I think a simple :
<?php if (isset($item->myValue)):?>
	<HTML TABLE HEADER COLUMN>
<?php endif; ?>


...

<?php if (isset($item->myValue)):?>
	<HTML TABLE CELL COLUMN>
<?php endif; ?>
}

For using this, you must be sure the item do not contain the unexpected columns (properties of the item)

Note : you can reuse the JHtml and JDom calls as well of course.
Coding is now a piece of cake
Last Edit: 06 Aug 2012 11:35 by admin. Reason: Better syntax
The administrator has disabled public write access.

Re: Getting query's column names 08 Aug 2012 08:16 #3067

  • jroberge
  • jroberge's Avatar
  • Offline
  • Junior Member
  • Posts: 23
  • Karma: 0
Admin,

Yes, it does work. It will recognize the presence of the column even if it is empty.

Thanks.
The administrator has disabled public write access.
Time to create page: 0.068 seconds

Get Started