SQL Statemant in Template

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

SQL Statemant in Template

orotherdf
Hi@all

is there any way to use SQL-Statemants in the templates?
Background: I will show the last Bug_ID in the Bug - Creation Process.
So i think a good way is to use the sql-statemant
SELECT MAX(bug_id) FROM `bugs`
in the template file create.html.tmpl
_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.
Reply | Threaded
Open this post in threaded view
|

Re: SQL Statemant in Template

Gervase Markham
On 09/11/17 09:04, [hidden email] wrote:
> is there any way to use SQL-Statemants in the templates?

Not easily.

> Background: I will show the last Bug_ID in the Bug - Creation Process.
> So i think a good way is to use the sql-statemant
> SELECT MAX(bug_id) FROM `bugs`
> in the template file create.html.tmpl

But it won't necessarily be accurate, because people could be filing
bugs while this person is writing theirs. Why would you want to do this?

Gerv
_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.
Reply | Threaded
Open this post in threaded view
|

Re: SQL Statemant in Template

orotherdf
Am Donnerstag, 9. November 2017 09:20:04 UTC+1 schrieb Gervase Markham:
> On 09/11/17 09:04, [hidden email] wrote:
> > is there any way to use SQL-Statemants in the templates?

> But it won't necessarily be accurate, because people could be filing
> bugs while this person is writing theirs. Why would you want to do this?

Hi Gerv,

thanks for your answer.

We need the bug id, because at the same time we create a directory containing the bug-id. Then we copy this directory path into the url field.

The risk that two people can create bugs at the same time is known to us. We accept that.

_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.
Reply | Threaded
Open this post in threaded view
|

Re: SQL Statemant in Template

orotherdf
Am Donnerstag, 9. November 2017 10:41:11 UTC+1 schrieb Thorsten Schöning:

> That sounds like a very error prone approach and you should consider
> implementing an extension that does all that for you. There are hooks
> available so you can run arbitrary code before/after the bug has been
> created, maybe create the directory in that code, but at least set the
> URL to the directory you need.

Hello Mr. Schöning,

thank you for this detailed explanation!

Now i have created an extension named ShowBugID (with the create.pl).
I found the following in the documentation:
"If your extension wants to implement a hook, all you have to do is write a subroutine in your hook package that has the same name as the hook."

So where do I have to enter my subroutine?

 sub bug_end_of_create {
     my ($self, $args) = @_;
     my $bugid = $args->{bugid};
     print "I got $bugid!\n";
 }
_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.
Reply | Threaded
Open this post in threaded view
|

Re: SQL Statemant in Template

Gervase Markham
In reply to this post by orotherdf
On 09/11/17 09:48, [hidden email] wrote:
> We need the bug id, because at the same time we create a directory
> containing the bug-id. Then we copy this directory path into the url
> field.

Why not instead have Bugzilla automatically generate the contents of the
URL field when the bug is filed, based on the actual bug number. And
then, once the bug is filed and shown to the user and they know the bug
number, they can go and create the directory.

Gerv
_______________________________________________
support-bugzilla mailing list
[hidden email]
https://lists.mozilla.org/listinfo/support-bugzilla
PLEASE put [hidden email] in the To: field when you reply.