For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > June 2005 > LiveUser applications









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author LiveUser applications
Rodrigo Alvarez

2005-06-09, 3:57 pm

Hi PEARs,

I'm using Alan Knowles' HTML_FlexyFramework as backed for my own
Framework/CMS. All requests pass through a Main class, where LiveUser is
instantiated, to check user rights. SEF URLs are used (for example
index.php/Section/Page/).

I will implement a Site tree through liveuser_applications, and map url
aliases to "real" liveuser_applications. This allow the framework to
point for example index.php/How_to_use_this (which doesn't exist really)
to index.php/Manual/View/12.

The question is, how can I add each requested url to
liveuser_applications (using LiveUser_Admin addApplication method),
automatically, without incrementing the liveuser_applications_seq table?

Calling getApplications, and checking that the requested one is not
present, would be the way, but this means an "extra" query to the
database on each page request. I could be that caching getApplications
query in any manner after each addAplication call solves the problem.
Another way is to force the application_define_name field to be UNIQUE,
and application_id auto_increment (MySQL), but this makes my framework
not portable.

Any ideas?

Thanks in advance,

Rodrigo Alvarez.
Lukas Smith

2005-06-09, 8:57 pm

Rodrigo Alvarez wrote:

> The question is, how can I add each requested url to
> liveuser_applications (using LiveUser_Admin addApplication method),
> automatically, without incrementing the liveuser_applications_seq table?


The solution would be to overwrite the definition of the
'application_id' field in the 'applications' table. By default its
defined to be 'seq'. You can change it to true or false or some name.

'seq' means use a sequence,
true means required,
false means not required,
name means create a compound index on all fields with the same name

put this into your config ...

'permContainer' => array(
'tables' => array(
'applications' => array(
'fields' => array('application_id' => true),
),
),
),

> Calling getApplications, and checking that the requested one is not
> present, would be the way, but this means an "extra" query to the
> database on each page request. I could be that caching getApplications
> query in any manner after each addAplication call solves the problem.
> Another way is to force the application_define_name field to be UNIQUE,
> and application_id auto_increment (MySQL), but this makes my framework
> not portable.


eventually we will add observers to facilitate caching in the admin part.

anyways i dont really understand what you are trying to do. are you just
trying to use a string as the application_id? in that case you would
also need to change the application_id type. also the seq is not used if
you explicitly pass a value for application_id when you pass the data
for to add*() methods.

regards,
Lukas
Rodrigo Alvarez

2005-06-09, 8:57 pm

Lukas Smith wrote:
>
>
>
> The solution would be to overwrite the definition of the
> 'application_id' field in the 'applications' table. By default its
> defined to be 'seq'. You can change it to true or false or some name.
>
>
> put this into your config ...
>
> 'permContainer' => array(
> 'tables' => array(
> 'applications' => array(
> 'fields' => array('application_id' => true),
> ),
> ),
> ),


I'll give it a try. This could solve the problem.

>
> anyways i dont really understand what you are trying to do. are you just
> trying to use a string as the application_id? in that case you would
> also need to change the application_id type. also the seq is not used if
> you explicitly pass a value for application_id when you pass the data
> for to add*() methods.

No, i will use application_define_name, as normal. The problem is that
inserting a name that already exists, doesn't really inserts data (as
expected), but increments the sequence (I don't want this).

Regards,

Rodrigo.
Lukas Smith

2005-06-09, 8:57 pm

Rodrigo Alvarez wrote:

> No, i will use application_define_name, as normal. The problem is that
> inserting a name that already exists, doesn't really inserts data (as
> expected), but increments the sequence (I don't want this).


Ah, well that can be worked around if you use MDB2 and set the
'force_seq' option in the permContainer to false. this will result in
using auto increment (you will have to manually add the autoincrement
for now) on all RDBMS that support auto increment.

regards,
Lukas
Lukas Smith

2005-06-09, 8:57 pm

Rodrigo Alvarez wrote:
> Lukas Smith wrote:
>
>
>
> I'll give it a try. This could solve the problem.


well it probably will not work for you, because then you are responsible
for generating new application_id's, which is not what you want ..

> No, i will use application_define_name, as normal. The problem is that
> inserting a name that already exists, doesn't really inserts data (as
> expected), but increments the sequence (I don't want this).


btw: what bugs you about this so much anyways? just annoyed by the
needless overhead?


regards,
Lukas
Rodrigo Alvarez Fernández

2005-06-09, 8:57 pm

On 6/10/05, Lukas Smith <lsmith@php.net> wrote:
> Rodrigo Alvarez wrote:
>=20
>=20
> Ah, well that can be worked around if you use MDB2 and set the
> 'force_seq' option in the permContainer to false. this will result in
> using auto increment (you will have to manually add the autoincrement
> for now) on all RDBMS that support auto increment.
>=20

Yes, that's why there is no ideal solution ;].

Thanks a lot, Lukas.

Rodrigo.
>

Rodrigo Alvarez

2005-06-10, 8:56 am


>
>
> btw: what bugs you about this so much anyways? just annoyed by the
> needless overhead?

Yes, a little bit.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com