Welcome, Guest
Username: Password: Remember me
EventList 1.0.2 for Joomla 1.6 - 2.5
  • Page:
  • 1
  • 2

TOPIC:

Custom query update DB - Help please. 5 years 9 months ago #16758

  • AchLive
  • AchLive's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 43
  • Thank you received: 3
Hi, I need your help.
I need to update a field of Community Builder when an event is added by the user from the front end.
You should add an update query that acts on the table #___comprofiler only if a new event has been added.
Unfortunately they are not very practical. I do not know where to add the query (in which code page) and how to build it.
Can anyone help me?

Joomla version 2.5.28
Eventlist version 1.0.2
Communiyu Builder Version 2.0.5
Type Field update numeric
Update operation in the query Decrease 1
Event for the query - Added new event only frontend.

Thank you in advance for your help

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

Custom query update DB - Help please. 5 years 9 months ago #16759

@AchLive,

maybe you can ask the qeustion in the forum of Community Builder too, but was wondering what the idea is of the field.

should it be displayed in a tab, is it only for statistics or is something else?
and what field do you want to increase?
(won't respond to PM)
==================================================================
running local: pre-alpha JEM 4.x (custom version) + Joomla 4.0.0beta3 + PHP 7.2.25
running live: jem2.3.0

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

Last edit: by Bluefox.

Custom query update DB - Help please. 5 years 9 months ago #16761

  • AchLive
  • AchLive's Avatar Topic Author
  • Offline
  • Senior Boarder
  • Senior Boarder
  • Posts: 43
  • Thank you received: 3
Hi Bluefox, thank you for the answer.
Community Builder is not the issue. I need to update a table field CB through the pages insertion new event.
Would a normal query update which unfortunately I do not know where to put (in which file and which position of the file).
I write an example of a query that should work
UPDATE `___comprofiler` SET `field_name` = field_name -1 WHERE `id` = '[user_id]';

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

Custom query update DB - Help please. 5 years 9 months ago #16762

Community Builder is not the issue

was just noting as it concerns a field in the comprofiler table and maybe there were people in that forum that would like to help you out.

but well,..
as you say you would to update the field after the insert of a new event i would take a look at the store function of the event.
that function is located within com_eventlist/models/eventedit.php (line 471)


around line 750, before the return you could add some code so it will be looking like
if (!$edited) {

	$userid = $user->get('id');
	$db			= JFactory::getDBO();
	$query = 'UPDATE #__comprofiler SET field_name = -1 WHERE id = '.$userid;
				$db->SetQuery( $query );
				$db->Query();

}

return $row->id

it's after the store of a new item and the edited variable is there as we will have an id after the id is stored no matter if it was a new event or an edit.

ps. didn't test the code so you have to tweak it a bit
(won't respond to PM)
==================================================================
running local: pre-alpha JEM 4.x (custom version) + Joomla 4.0.0beta3 + PHP 7.2.25
running live: jem2.3.0
The following user(s) said Thank You: AchLive

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

Last edit: by Bluefox. Reason: renamed com_jem to com_evenlist

Custom query update DB - Help please. 5 years 9 months ago #16763

  • Hoffi
  • Hoffi's Avatar
  • Offline
  • Platinum Boarder
  • Platinum Boarder
  • Posts: 2279
  • Karma: 52
  • Thank you received: 449
@Bluefox: Just to note AchLive talks about EL, not JEM. ;)

@AchLive: But maybe in EL you can find a similar model with store() function "knowing" if event to store is new or edited.
Pessimists are optimists with experience!
The following user(s) said Thank You: AchLive

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

Custom query update DB - Help please. 5 years 9 months ago #16764

Hoffi wrote: @Bluefox: Just to note AchLive talks about EL, not JEM. ;)


whoops, meant com_eventlist.
did take a peak at the file of eventlist but prefixed it with com_jem :)
(won't respond to PM)
==================================================================
running local: pre-alpha JEM 4.x (custom version) + Joomla 4.0.0beta3 + PHP 7.2.25
running live: jem2.3.0

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

  • Page:
  • 1
  • 2
Time to create page: 0.226 seconds

Donate

If you find JEM useful and if you use it on your site, please consider a donation to the project.

Private Messages

You are not logged in.

Follow us......