Re: [PHP] Re: Foreign Keys Question

2008-12-11 Thread clive

Robert Cummings wrote:

It depends on the data. Certainly for student enrolments I would want a
paper trail (so to speak) and would just set a status field. But if it
was say, an online shopping cart or cached data... I'd just purge it.

Cheers,
Rob.
  
yes - you are right, I was just thinking about the student enrolment 
scenario :-)



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Foreign Keys Question

2008-12-11 Thread Robert Cummings
On Fri, 2008-12-12 at 09:06 +0200, clive wrote:
> Colin Guthrie wrote:
> > 'Twas brillig, and tedd at 11/12/08 18:46 did gyre and gimble:
> >> As for my "Foreign Keys Question", I think the answer is that it 
> >> enforces rules upon the configuration (i.e., deleting, altering, and 
> >> such), but does not provide any significant service beyond that.
> >
> > Well that's a fairly significant service in itself. The whole 
> > "deleting data" case is where FK's have saved me significant amount of 
> > coding.
> >
> > The ON DELETE CASCADE option is key here... "DELETE FROM students 
> > where student_id=1" will remove all traces of that student from the 
> > db... all the course they've attended, all the instructors who have 
> > taught them etc. keeps things nice and tidy without having to put the 
> > structure in your code all over the place.
> >
> > Col
> >
> Is it just me or does anyone else here not like deleting from a 
> database, I normally have a status field to indicated if a row has been 
> deleted.
> 
> What about historical data, would you not want to know that studentX was 
> enrolled at some point in the past, if you just delete that student and 
> all related data how would you know this?
> 
> You could also have a 2nd database with the same table structure and 
> move old/delete data into there.

It depends on the data. Certainly for student enrolments I would want a
paper trail (so to speak) and would just set a status field. But if it
was say, an online shopping cart or cached data... I'd just purge it.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Foreign Keys Question

2008-12-11 Thread clive

Colin Guthrie wrote:

'Twas brillig, and tedd at 11/12/08 18:46 did gyre and gimble:
As for my "Foreign Keys Question", I think the answer is that it 
enforces rules upon the configuration (i.e., deleting, altering, and 
such), but does not provide any significant service beyond that.


Well that's a fairly significant service in itself. The whole 
"deleting data" case is where FK's have saved me significant amount of 
coding.


The ON DELETE CASCADE option is key here... "DELETE FROM students 
where student_id=1" will remove all traces of that student from the 
db... all the course they've attended, all the instructors who have 
taught them etc. keeps things nice and tidy without having to put the 
structure in your code all over the place.


Col

Is it just me or does anyone else here not like deleting from a 
database, I normally have a status field to indicated if a row has been 
deleted.


What about historical data, would you not want to know that studentX was 
enrolled at some point in the past, if you just delete that student and 
all related data how would you know this?


You could also have a 2nd database with the same table structure and 
move old/delete data into there.


Clive


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] How serialize DOMDocument object?

2008-12-11 Thread Михаил Гаврилов
How serialize DOMDocument object?


Re: [PHP] Need a brain to bounce some Mysql/DB thoughts off of!!

2008-12-11 Thread German Geek
OK, i give u that, Rob. :-) I might just ask MySQL questions here, if i have
some.

I guess, if people get more responses here, it shows that this mailing list
is superior (no offence to the MySQL list :-P ).

Tim

On Fri, Dec 12, 2008 at 4:04 PM, Robert Cummings wrote:

> It's Christmas... the season of giving and tolerance :|
>
>
> On Fri, 2008-12-12 at 13:56 +1300, German Geek wrote:
> > This list seems to be turning into a MySQL list with a few PHP
> questions...
> > Tim-Hinnerk Heuer
> >
> > http://www.ihostnz.com
> >
> >
> > On Fri, Dec 12, 2008 at 1:53 PM, bruce  wrote:
> >
> > > Hi guys.
> > >
> > > Architecting an app that's going to have users interacting with
> different
> > > levels of the db/tbls, and trying to figure out a few things.
> > >
> > > The highlevel layout looks like:
> > >  collegeTBL
> > >  deptTBL
> > >
> > >  with ->collegeTBL.id = deptTBL.colID
> > >
> > > I also have a status tbl for each collegeTBL/deptTBL
> > >
> > >  college_statusTBL
> > >   userID
> > >   collegeID
> > >
> > >  dept_statusTBL
> > >   userID
> > >   deptID
> > >
> > >  with:
> > >  collegeTBL.id=college_statusTBL.collegeID
> > >  deptTBL.id=dept_statusTBL.deptID
> > >
> > > So I limk the statusTBLs to the college/dept TBLs...
> > >
> > > This is due to the fact that a user can elect to work on either a
> college,
> > > or a given dept of the college.
> > >
> > > I'm struggling with a good/best way to figure out how to develop a
> query to
> > > determine what level of a college, (if any) a user has elected to work
> > > with.
> > >
> > > I can do a multiple join across the collegeTBL/deptTBL, and the
> statusTBLs,
> > > but this simply gets a large tbl, and I'd have to then parse the
> results...
> > > I'm trying to figure out if there's a better way, with a single query.
> The
> > > query would look at the college(status), and then at the dept(status)
> to
> > > determine what level (if any ) the user has selected.
> > >
> > > I've got a mysql layout of the various tbls, and inserts if anyone's
> > > interested in helping me shake my mind out on this...
> > >
> > > thanks
> > >
> > > -bruce
> > >
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> --
> http://www.interjinn.com
> Application and Templating Framework for PHP
>
>


Re: [PHP] Foreign Keys Question

2008-12-11 Thread Chris

Waynn Lue wrote:

As a side note, FKs do enforce other table specific properties like
indexes on the fields being constrained, so they do add value there as
well. But there's of course an extra cost on updates and inserts to
see if the FK is violated.


On the external table? No they don't.

mysql> create table t1(id int primary key, name varchar(255)) engine=innodb;
Query OK, 0 rows affected (0.00 sec)

mysql> create table t2(t2id int, t1id int references t1(id)) engine=innodb;
Query OK, 0 rows affected (0.00 sec)

mysql> show create table t2\G
*** 1. row ***
   Table: t2
Create Table: CREATE TABLE `t2` (
  `t2id` int(11) default NULL,
  `t1id` int(11) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)


No auto-index on t2(t1id) at all. You have to define that yourself - you 
might want it part of a multi-column index for example.


You definitely should index it, but it won't happen automatically.

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Foreign Keys Question

2008-12-11 Thread Waynn Lue
As a side note, FKs do enforce other table specific properties like
indexes on the fields being constrained, so they do add value there as
well. But there's of course an extra cost on updates and inserts to
see if the FK is violated.

Waynn

On 12/11/08, Colin Guthrie  wrote:
> 'Twas brillig, and Chris at 12/12/08 01:20 did gyre and gimble:
>> Micah Gersten wrote:
>>> Colin Guthrie wrote:
 The ON DELETE CASCADE option is key here... "DELETE FROM students
 where student_id=1" will remove all traces of that student from the
 db... all the course they've attended, all the instructors who have
 taught them etc. keeps things nice and tidy without having to put the
 structure in your code all over the place.

 Col

>>> Why would you want to delete the instructors when deleting the student?
>>
>> I think he meant the link between the student & instructor (in the
>> student_instructor table), not the instructor itself.
>
> lol, indeed, that's what I meant... Sorry I thought it was implied in
> the context!
>
> Say you have the following layouts
>
> instructors: instructor_id, name
> students: student_id, name
> instructor_students: instructor_id, student_id
>
>
> This structure would hold a list of instructors and a list of studends
> and also a one to many mapping of instructors to students.
>
> If you delete a student the FK can cascade to the instructor_students
> table and thus delete the records that indicate a given instructor (or
> instructors) taught them.
>
> Col
>
>
> --
>
> Colin Guthrie
> gmane(at)colin.guthr.ie
> http://colin.guthr.ie/
>
> Day Job:
>Tribalogic Limited [http://www.tribalogic.net/]
> Open Source:
>Mandriva Linux Contributor [http://www.mandriva.com/]
>PulseAudio Hacker [http://www.pulseaudio.org/]
>Trac Hacker [http://trac.edgewall.org/]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need a brain to bounce some Mysql/DB thoughts off of!!

2008-12-11 Thread Robert Cummings
It's Christmas... the season of giving and tolerance :|


On Fri, 2008-12-12 at 13:56 +1300, German Geek wrote:
> This list seems to be turning into a MySQL list with a few PHP questions...
> Tim-Hinnerk Heuer
> 
> http://www.ihostnz.com
> 
> 
> On Fri, Dec 12, 2008 at 1:53 PM, bruce  wrote:
> 
> > Hi guys.
> >
> > Architecting an app that's going to have users interacting with different
> > levels of the db/tbls, and trying to figure out a few things.
> >
> > The highlevel layout looks like:
> >  collegeTBL
> >  deptTBL
> >
> >  with ->collegeTBL.id = deptTBL.colID
> >
> > I also have a status tbl for each collegeTBL/deptTBL
> >
> >  college_statusTBL
> >   userID
> >   collegeID
> >
> >  dept_statusTBL
> >   userID
> >   deptID
> >
> >  with:
> >  collegeTBL.id=college_statusTBL.collegeID
> >  deptTBL.id=dept_statusTBL.deptID
> >
> > So I limk the statusTBLs to the college/dept TBLs...
> >
> > This is due to the fact that a user can elect to work on either a college,
> > or a given dept of the college.
> >
> > I'm struggling with a good/best way to figure out how to develop a query to
> > determine what level of a college, (if any) a user has elected to work
> > with.
> >
> > I can do a multiple join across the collegeTBL/deptTBL, and the statusTBLs,
> > but this simply gets a large tbl, and I'd have to then parse the results...
> > I'm trying to figure out if there's a better way, with a single query. The
> > query would look at the college(status), and then at the dept(status) to
> > determine what level (if any ) the user has selected.
> >
> > I've got a mysql layout of the various tbls, and inserts if anyone's
> > interested in helping me shake my mind out on this...
> >
> > thanks
> >
> > -bruce
> >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Can GD make a JPG thumbnail of a PDF?

2008-12-11 Thread Patrick Moloney
It looks like there is something wrong with your newsreader because your 
replies are not being connected to what you are replying to. Have you 
noticed? Much harder for everyone. What newsreader are you using?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Foreign Keys Question

2008-12-11 Thread Colin Guthrie

'Twas brillig, and Chris at 12/12/08 01:20 did gyre and gimble:

Micah Gersten wrote:

Colin Guthrie wrote:

The ON DELETE CASCADE option is key here... "DELETE FROM students
where student_id=1" will remove all traces of that student from the
db... all the course they've attended, all the instructors who have
taught them etc. keeps things nice and tidy without having to put the
structure in your code all over the place.

Col


Why would you want to delete the instructors when deleting the student?


I think he meant the link between the student & instructor (in the 
student_instructor table), not the instructor itself.


lol, indeed, that's what I meant... Sorry I thought it was implied in 
the context!


Say you have the following layouts

instructors: instructor_id, name
students: student_id, name
instructor_students: instructor_id, student_id


This structure would hold a list of instructors and a list of studends 
and also a one to many mapping of instructors to students.


If you delete a student the FK can cascade to the instructor_students 
table and thus delete the records that indicate a given instructor (or 
instructors) taught them.


Col


--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Foreign Keys Question

2008-12-11 Thread Chris

Micah Gersten wrote:

Colin Guthrie wrote:

The ON DELETE CASCADE option is key here... "DELETE FROM students
where student_id=1" will remove all traces of that student from the
db... all the course they've attended, all the instructors who have
taught them etc. keeps things nice and tidy without having to put the
structure in your code all over the place.

Col


Why would you want to delete the instructors when deleting the student?


I think he meant the link between the student & instructor (in the 
student_instructor table), not the instructor itself.


--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Re: Foreign Keys Question

2008-12-11 Thread Micah Gersten
Colin Guthrie wrote:
> The ON DELETE CASCADE option is key here... "DELETE FROM students
> where student_id=1" will remove all traces of that student from the
> db... all the course they've attended, all the instructors who have
> taught them etc. keeps things nice and tidy without having to put the
> structure in your code all over the place.
>
> Col
>
Why would you want to delete the instructors when deleting the student?

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Need a brain to bounce some Mysql/DB thoughts off of!!

2008-12-11 Thread German Geek
This list seems to be turning into a MySQL list with a few PHP questions...
Tim-Hinnerk Heuer

http://www.ihostnz.com


On Fri, Dec 12, 2008 at 1:53 PM, bruce  wrote:

> Hi guys.
>
> Architecting an app that's going to have users interacting with different
> levels of the db/tbls, and trying to figure out a few things.
>
> The highlevel layout looks like:
>  collegeTBL
>  deptTBL
>
>  with ->collegeTBL.id = deptTBL.colID
>
> I also have a status tbl for each collegeTBL/deptTBL
>
>  college_statusTBL
>   userID
>   collegeID
>
>  dept_statusTBL
>   userID
>   deptID
>
>  with:
>  collegeTBL.id=college_statusTBL.collegeID
>  deptTBL.id=dept_statusTBL.deptID
>
> So I limk the statusTBLs to the college/dept TBLs...
>
> This is due to the fact that a user can elect to work on either a college,
> or a given dept of the college.
>
> I'm struggling with a good/best way to figure out how to develop a query to
> determine what level of a college, (if any) a user has elected to work
> with.
>
> I can do a multiple join across the collegeTBL/deptTBL, and the statusTBLs,
> but this simply gets a large tbl, and I'd have to then parse the results...
> I'm trying to figure out if there's a better way, with a single query. The
> query would look at the college(status), and then at the dept(status) to
> determine what level (if any ) the user has selected.
>
> I've got a mysql layout of the various tbls, and inserts if anyone's
> interested in helping me shake my mind out on this...
>
> thanks
>
> -bruce
>
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[PHP] Need a brain to bounce some Mysql/DB thoughts off of!!

2008-12-11 Thread bruce
Hi guys.

Architecting an app that's going to have users interacting with different
levels of the db/tbls, and trying to figure out a few things.

The highlevel layout looks like:
 collegeTBL
 deptTBL

 with ->collegeTBL.id = deptTBL.colID

I also have a status tbl for each collegeTBL/deptTBL

 college_statusTBL
   userID
   collegeID

 dept_statusTBL
   userID
   deptID

 with:
  collegeTBL.id=college_statusTBL.collegeID
  deptTBL.id=dept_statusTBL.deptID

So I limk the statusTBLs to the college/dept TBLs...

This is due to the fact that a user can elect to work on either a college,
or a given dept of the college.

I'm struggling with a good/best way to figure out how to develop a query to
determine what level of a college, (if any) a user has elected to work with.

I can do a multiple join across the collegeTBL/deptTBL, and the statusTBLs,
but this simply gets a large tbl, and I'd have to then parse the results...
I'm trying to figure out if there's a better way, with a single query. The
query would look at the college(status), and then at the dept(status) to
determine what level (if any ) the user has selected.

I've got a mysql layout of the various tbls, and inserts if anyone's
interested in helping me shake my mind out on this...

thanks

-bruce




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] how to not show login info in the url ...what am I looking for?

2008-12-11 Thread Ashley Sheridan
On Fri, 2008-12-12 at 10:59 +1300, German Geek wrote:
> On Fri, Dec 12, 2008 at 7:03 AM, tedd  wrote:
> 
> > At 11:23 AM -0500 12/11/08, Robert Cummings wrote:
> >
> >> On Thu, 2008-12-11 at 11:05 -0500, tedd wrote:
> >>  > When I say "Hack a site" I mean to do something to get the site to
> >>
> >>>  provide an unintended result as  expected by the author.
> >>>
> >>>  Much like using CSS "Hacks" to get browsers to do something that was
> >>>  not intended by the original designers.
> >>>
> >>>  On the other hand, my understanding of "cracking" means to "crack"
> >>>  some type of encryption. Thus, the reason why I did not say "cracking
> >>>  the site" instead of "hacking the site".
> >>>
> >>
> >> Cracking is not just about encryption. It's about bypassing any kind of
> >> measure put in place to prevent someone from doing something. Hacking on
> >> the other hand does not embody this principle, although hacking may be
> >> employed to achieve cracking. Just because pop culture is completely
> >> ignorant to the difference, doesn't mean you as a member of the
> >> community need to jump on board and bleat like a sheep. If you intend to
> >> misuse hacker, then you should at least provide more detail such as
> >> white-, grey-, or black-hat.
> >>
> >> Cheers,
> >> Rob.
> >>
> >
> >
> > Okay, I shall adjust my fracking terminology. :-)
> >
> > Cheers,
> >
> > tedd
> >
> 
> Cracking to me is when someone uses an already existing hack to use it for
> their own gain in a malicious way to someone else.
> Hacking is finding new security holes or problems with some software to fix
> the security holes, or just for fun without causing any demage or revealing
> sensitive information.
> A hacker to me, is an admirable person, who can find new security issues.
> A cracker to me, is someone exploiting hacks already in existence.
I tend to agree with these definitions:

http://searchsecurity.techtarget.com/sDefinition/0,,sid14_gci212220,00.html

The hacker is generally considered to be someone knowledgeable about a
specific aspect of computers and uses that. This can obviously be used
for good or ill. Cracker is generally a non-hacker (IMHO) that uses the
works of hackers to break into things. The general media has this a bit
messed up, and a hacker to them is typically someone who breaks into
systems with malicious intent.

Of course, the other meanings:

hacker: someone who chops down trees
cracker: something you pull at xmas (can be of the female
persuasion ;) )


Ash
www.ashleysheridan.co.uk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Poll of Sorts: Application Frameworks--Zend, Cake etc

2008-12-11 Thread Colin Guthrie

'Twas brillig, and Terion Miller at 11/12/08 14:56 did gyre and gimble:

Hey Everyone, I am wondering if using a framework such as one of these may
make my life easier, which do any of you use and what has been your
experience with the learning curve of them?
I just put Cake on my local server, basically I want to know which is
easiest? LOL...


Personally I'm a ZF fan, but each to their own.

Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: Foreign Keys Question

2008-12-11 Thread Colin Guthrie

'Twas brillig, and tedd at 11/12/08 18:46 did gyre and gimble:
As for my "Foreign Keys Question", I think the answer is that it 
enforces rules upon the configuration (i.e., deleting, altering, and 
such), but does not provide any significant service beyond that.


Well that's a fairly significant service in itself. The whole "deleting 
data" case is where FK's have saved me significant amount of coding.


The ON DELETE CASCADE option is key here... "DELETE FROM students where 
student_id=1" will remove all traces of that student from the db... all 
the course they've attended, all the instructors who have taught them 
etc. keeps things nice and tidy without having to put the structure in 
your code all over the place.


Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] how to not show login info in the url ...what am I looking for?

2008-12-11 Thread German Geek
On Fri, Dec 12, 2008 at 7:03 AM, tedd  wrote:

> At 11:23 AM -0500 12/11/08, Robert Cummings wrote:
>
>> On Thu, 2008-12-11 at 11:05 -0500, tedd wrote:
>>  > When I say "Hack a site" I mean to do something to get the site to
>>
>>>  provide an unintended result as  expected by the author.
>>>
>>>  Much like using CSS "Hacks" to get browsers to do something that was
>>>  not intended by the original designers.
>>>
>>>  On the other hand, my understanding of "cracking" means to "crack"
>>>  some type of encryption. Thus, the reason why I did not say "cracking
>>>  the site" instead of "hacking the site".
>>>
>>
>> Cracking is not just about encryption. It's about bypassing any kind of
>> measure put in place to prevent someone from doing something. Hacking on
>> the other hand does not embody this principle, although hacking may be
>> employed to achieve cracking. Just because pop culture is completely
>> ignorant to the difference, doesn't mean you as a member of the
>> community need to jump on board and bleat like a sheep. If you intend to
>> misuse hacker, then you should at least provide more detail such as
>> white-, grey-, or black-hat.
>>
>> Cheers,
>> Rob.
>>
>
>
> Okay, I shall adjust my fracking terminology. :-)
>
> Cheers,
>
> tedd
>

Cracking to me is when someone uses an already existing hack to use it for
their own gain in a malicious way to someone else.
Hacking is finding new security holes or problems with some software to fix
the security holes, or just for fun without causing any demage or revealing
sensitive information.
A hacker to me, is an admirable person, who can find new security issues.
A cracker to me, is someone exploiting hacks already in existence.


Re: [PHP] Foreign Keys Question

2008-12-11 Thread Robert Cummings
On Thu, 2008-12-11 at 16:24 -0500, Robert Cummings wrote:
> On Thu, 2008-12-11 at 16:17 -0500, tedd wrote:
> > At 3:14 PM -0500 12/11/08, Andrew Ballard wrote:
> > >
> > >That's the way to go. Just keep in mind that you will have to consider
> > >ways of preventing overloading your courses due to concurrency,
> > >whether you use table locks or devise your own mechanism. I don't know
> > >if you are allowing students to self-enroll or not. You just don't
> > >want two users to both see that a course has one opening left and both
> > >try to take that spot at the same time.
> > >
> > >Andrew
> > 
> > It's very low volume at the moment, so I don't think there will be an 
> > immediate problem.
> > 
> > However, I will investigate locking the tables for entry. But I don't 
> > think using transactions will be necessary.
> 
> A site doesn't need to be high volume to get a concurrency issue. The
> timing just needs to be right. So there's less probability in a low
> traffic site, but all the same, the problem produced as a result is the
> same. In a low volume site using a lock on the table is a simple method
> to prevent the problem since you can expect it will have minimal impact
> on the site in general (due to low volume). You only need the lock when
> you go to add the row...
> 
> lock table
> check enrolment count
> no room
> unlock table
> generate error
> have room
> insert row
> unlock table
> 
> Ba da boom.

I should have read your message better... you were talking about
skipping transactions and not locking :)

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Foreign Keys Question

2008-12-11 Thread Robert Cummings
On Thu, 2008-12-11 at 16:17 -0500, tedd wrote:
> At 3:14 PM -0500 12/11/08, Andrew Ballard wrote:
> >
> >That's the way to go. Just keep in mind that you will have to consider
> >ways of preventing overloading your courses due to concurrency,
> >whether you use table locks or devise your own mechanism. I don't know
> >if you are allowing students to self-enroll or not. You just don't
> >want two users to both see that a course has one opening left and both
> >try to take that spot at the same time.
> >
> >Andrew
> 
> It's very low volume at the moment, so I don't think there will be an 
> immediate problem.
> 
> However, I will investigate locking the tables for entry. But I don't 
> think using transactions will be necessary.

A site doesn't need to be high volume to get a concurrency issue. The
timing just needs to be right. So there's less probability in a low
traffic site, but all the same, the problem produced as a result is the
same. In a low volume site using a lock on the table is a simple method
to prevent the problem since you can expect it will have minimal impact
on the site in general (due to low volume). You only need the lock when
you go to add the row...

lock table
check enrolment count
no room
unlock table
generate error
have room
insert row
unlock table

Ba da boom.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Foreign Keys Question

2008-12-11 Thread tedd

At 3:14 PM -0500 12/11/08, Andrew Ballard wrote:


That's the way to go. Just keep in mind that you will have to consider
ways of preventing overloading your courses due to concurrency,
whether you use table locks or devise your own mechanism. I don't know
if you are allowing students to self-enroll or not. You just don't
want two users to both see that a course has one opening left and both
try to take that spot at the same time.

Andrew


It's very low volume at the moment, so I don't think there will be an 
immediate problem.


However, I will investigate locking the tables for entry. But I don't 
think using transactions will be necessary.


Thanks again for all the help Andrew el al.

Cheers,

tedd
--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] trying to figure out how to create the right query...

2008-12-11 Thread bruce
Hi.

I have the following test db/tbl setup. 

stateTBL
+--+
| stateName|
| stateID  |>>>+
+--+   V
   V
   V
collegeTBL V
+--+   V
| collegeName  |   V
| stateID  |<<<+
| collegeID|>>>+
+--+   V
   V
   V
deptTBLV
+--+   V
| deptName |   V
| collegeID|<<<+
| deptID   |>>>+
+--+   V
   V
   V
courseTBL  V
+--+   V
| courseName   |   V
| deptID   |<<<+
| courseID |>>>+
+--+   V
   V
   V
facultyTBL V
+--+   V
| facultyName  |   V
| courseID |<<<+
| ID   |
+--+


my intended app will allow the user to select a given
 item (college, dept, course, faculty) and to store
 this data. when a user is displaying a list of
 items, i'd like to have my app determine if the
 child of the item has been selected by the user.

so. if a user has selected stanford, i'd like to
 be able to have a query that returns 'true' for
 any item, that has a 'child' (leaf) already selected by
 the user. (this should work for any level of
 childTBL)

so if a user has selected a course, from the 
 stanford, physics dept, physics 101, i'd like to 
 have a query that returns 'true' if the user 
 selects 'stanford' from the list of colleges...

i can't quite seem to figure out the sql to make it happen...

thoughts/comments/etc..


i'm hoping that this makes sense!!

thanks



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Foreign Keys Question

2008-12-11 Thread Andrew Ballard
On Thu, Dec 11, 2008 at 2:32 PM, tedd  wrote:
> At 1:55 PM -0500 12/11/08, Robert Cummings wrote:
>>
>> Student attendance should be a table with rows for each student in
>> attendance. If you want to limit the number make a check before adding
>> another student. Don't hard code the number via fields like above or
>> you'll find it overly ugly to add/remove students or even increase the
>> number of allowed students. As it stands to allow 6 students you would
>> have to add 2 more columns. With attendance controled by a table with a
>> row for ewach attendance you would only need to update a configuration
>> variable the determines the maximim number of allowed students in
>> attendance.
>>
>> Cheers,
>> Rob.
>
> Rob:
>
> I see -- the solution is a table for courses, students, instructors and
> enrollment.
>
> The enrollment table will hold links to all (third normal).
>
> If I want to limit the number of students in a course, then just count the
> number of students enrolled in a specific course within the enrollment table
> and check that number against the maximum allowed before adding another
> enrollment record.
>
> Also, if a student cancels, then it's only a deletion of an enrollment
> record and all is right with the world.
>
> That's good.
>
> Sometimes it's good to talk things like this through -- clears the fuzzy
> thinking.
>
> Thanks,
>
> tedd
>

That's the way to go. Just keep in mind that you will have to consider
ways of preventing overloading your courses due to concurrency,
whether you use table locks or devise your own mechanism. I don't know
if you are allowing students to self-enroll or not. You just don't
want two users to both see that a course has one opening left and both
try to take that spot at the same time.

Andrew

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Poll of Sorts: Application Frameworks--Zend, Cake etc

2008-12-11 Thread Boyd, Todd M.
> -Original Message-
> From: Eric Butera [mailto:eric.but...@gmail.com]
> Sent: Thursday, December 11, 2008 9:25 AM
> To: Bastien Koert
> Cc: Terion Miller; PHP General
> Subject: Re: [PHP] Poll of Sorts: Application Frameworks--Zend, Cake
> etc
> 
> On Thu, Dec 11, 2008 at 10:22 AM, Bastien Koert 
> wrote:
> >
> >
> > On Thu, Dec 11, 2008 at 10:15 AM, Eric Butera 
> wrote:
> >>
> >> On Thu, Dec 11, 2008 at 9:56 AM, Terion Miller
> >> wrote:
> >> > Hey Everyone, I am wondering if using a framework such as one of
> these
> >> > may
> >> > make my life easier, which do any of you use and what has been
> your
> >> > experience with the learning curve of them?
> >> > I just put Cake on my local server, basically I want to know which
> is
> >> > easiest? LOL...
> >> >
> >>
> >> Define easiest.  What is it that you need to code?  If you mean
> cookie
> >> cutter sites that have been done a million times with minimal
> >> flexibility... :)  I'm in the same boat as you though.  I don't know
> >> which one meets the needs I have the best.  There's stuff like cake
> >> which is really easy to start up, then there's stuff like symphony
> >> that will let you do anything, but you really have to work at it.
> >
> > There are definite learning curves when picking these up.
> >
> > symfony and ZF have the largest because they either do more (symfony)
> or are
> > designed to be used piecemeal (ZF)
> >
> > CodeIgnitor is one of the easiest ones to start using with Cake not
> far
> 
> One huge part of this that I didn't mention before is the community
> around the frameworks too.  Do they have good docs, examples, stuff
> like that.  Can you ask questions and get quality answers?

I see people talk about the same handful of frameworks every time this question 
comes up. Has anyone used one of the underdog frameworks that are sprouting up 
at the fringes?

PRADO?
Yii?
Simple PHP Framework?
Akelos (Ruby on Rails port)?
Seagull?
BlueShoes?
EvoCore?
PHOCOA?
Zoop?
Stratos?
Picora?
SOLAR?
FLOW3?
Maintainable?
Adventure-Framework?
...the list goes on.

I thought Yii [1] seemed interesting, at the least.

1. http://www.yiiframework.com


// Todd


[PHP] Re: [PHP-QA] Re: [PHP] Quick question regarding $_SESSION and header()

2008-12-11 Thread Ólafur Waage
Whoops, sent the thanks to the wrong list :P

On Thu, Dec 11, 2008 at 7:33 PM, Daniel Brown  wrote:
> (Forwarding back to PHP General for the archives.)
>
> On Thu, Dec 11, 2008 at 14:31, Ólafur Waage  wrote:
>> Its fixed, thanks guys :)
>>
>> On Thu, Dec 11, 2008 at 7:16 PM, Daniel Brown  wrote:
>>> On Thu, Dec 11, 2008 at 14:01, Ólafur Waage  wrote:
 I should be able to set a session var and then do a header redirect
 right? Small bug regarding that and i just need to be sure.
>>>
>>>This isn't a bug in PHP, it's actually in adherance with HTTP
>>> standards (and current browser standards).  Prior to doing a header()
>>> redirect, you have to force the cookie to be written with
>>> session_write_close().
>>>
>>> --
>>> 
>>> http://www.parasane.net/
>>> daniel.br...@parasane.net || danbr...@php.net
>>> 50% Off Hosting! http://www.pilotpig.net/specials.php
>>>
>>
>> --
>> PHP Quality Assurance Mailing List 
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
>
> --
> 
> http://www.parasane.net/
> daniel.br...@parasane.net || danbr...@php.net
> 50% Off Hosting! http://www.pilotpig.net/specials.php
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: [PHP-QA] Re: [PHP] Quick question regarding $_SESSION and header()

2008-12-11 Thread Daniel Brown
(Forwarding back to PHP General for the archives.)

On Thu, Dec 11, 2008 at 14:31, Ólafur Waage  wrote:
> Its fixed, thanks guys :)
>
> On Thu, Dec 11, 2008 at 7:16 PM, Daniel Brown  wrote:
>> On Thu, Dec 11, 2008 at 14:01, Ólafur Waage  wrote:
>>> I should be able to set a session var and then do a header redirect
>>> right? Small bug regarding that and i just need to be sure.
>>
>>This isn't a bug in PHP, it's actually in adherance with HTTP
>> standards (and current browser standards).  Prior to doing a header()
>> redirect, you have to force the cookie to be written with
>> session_write_close().
>>
>> --
>> 
>> http://www.parasane.net/
>> daniel.br...@parasane.net || danbr...@php.net
>> 50% Off Hosting! http://www.pilotpig.net/specials.php
>>
>
> --
> PHP Quality Assurance Mailing List 
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>



-- 

http://www.parasane.net/
daniel.br...@parasane.net || danbr...@php.net
50% Off Hosting! http://www.pilotpig.net/specials.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Foreign Keys Question

2008-12-11 Thread tedd

At 1:55 PM -0500 12/11/08, Robert Cummings wrote:

Student attendance should be a table with rows for each student in
attendance. If you want to limit the number make a check before adding
another student. Don't hard code the number via fields like above or
you'll find it overly ugly to add/remove students or even increase the
number of allowed students. As it stands to allow 6 students you would
have to add 2 more columns. With attendance controled by a table with a
row for ewach attendance you would only need to update a configuration
variable the determines the maximim number of allowed students in
attendance.

Cheers,
Rob.


Rob:

I see -- the solution is a table for courses, students, instructors 
and enrollment.


The enrollment table will hold links to all (third normal).

If I want to limit the number of students in a course, then just 
count the number of students enrolled in a specific course within the 
enrollment table and check that number against the maximum allowed 
before adding another enrollment record.


Also, if a student cancels, then it's only a deletion of an 
enrollment record and all is right with the world.


That's good.

Sometimes it's good to talk things like this through -- clears the 
fuzzy thinking.


Thanks,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Quick question regarding $_SESSION and header()

2008-12-11 Thread Daniel Brown
On Thu, Dec 11, 2008 at 14:01, Ólafur Waage  wrote:
> I should be able to set a session var and then do a header redirect
> right? Small bug regarding that and i just need to be sure.

This isn't a bug in PHP, it's actually in adherance with HTTP
standards (and current browser standards).  Prior to doing a header()
redirect, you have to force the cookie to be written with
session_write_close().

-- 

http://www.parasane.net/
daniel.br...@parasane.net || danbr...@php.net
50% Off Hosting! http://www.pilotpig.net/specials.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Foreign Keys Question

2008-12-11 Thread Robert Cummings
On Thu, 2008-12-11 at 13:56 -0500, tedd wrote:
> At 1:48 PM -0500 12/11/08, Robert Cummings wrote:
> >On Thu, 2008-12-11 at 13:27 -0500, Bastien Koert wrote:
> >  > On Thu, Dec 11, 2008 at 12:56 PM, tedd 
> >
> >  > > Does anyone have any example code to show me the actual syntax?
> >
> >  > Joins should allow you to pull the data from the table in one query
> >
> >You want to be careful using joins though. If you were to pull all that
> >data in one shot using joins you would create a large data transfer
> >mostly containing redundant data.
> >
> >Cheers,
> >Rob.
> 
> Rob:
> 
> Good point. Maybe my old way of doing that was the best. Simply get 
> the ID's needed from one table and then open the necessary tables 
> accordingly. In other words, stop worrying about the number of times 
> I'm going to the store to buy things because going once might result 
> in the things being too heavy for me to carry home -- if that makes

No, it's still good to think about the number of trips. For instance if
you are getting the number of students in attendance you may as well
join on the student table to get their individual data "if you need it".
Similarly, if for whatever reason you have 10 student IDs, but not the
student information itself, but you need to get said information... you
can just select them all in one query using an IN( id1, id2, ... )
clause.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Foreign Keys Question

2008-12-11 Thread phphelp -- kbk


On Dec 11, 2008, at 12:55 PM, Robert Cummings wrote:



On Thu, 2008-12-11 at 13:46 -0500, tedd wrote:


At 12:29 PM -0600 12/11/08, phphelp -- kbk wrote:


Hey tedd ---

Do I understand your structure correctly that you have something  
like:


Courses (table)
course_id,
subject_id,
student1_id,
student2_id,



That was right, but I think I've reconsidered.

You see, Richard pointed out the error of my ways, namely:







Student attendance should be a table with rows for each student in
attendance. If you want to limit the number make a check before adding
another student. Don't hard code the number via fields like above or
you'll find it overly ugly to add/remove students or even increase the



Right, Rob ---

As it happens I'm writing an application like this now, in late beta,  
ready to go live "any day now."


I call the table you are describing 'enrollment.'

So:


 - student_id,
 - (rest of the fields)


 - enroll_id
 - student_id
 - course_id
 - role_in_class
 - (more fields)


 - course_id
 - subject_id
 - (more)

Except I take it one more step: Instructors are just People, as are  
Students. The role_in_class field distinguishes what they are doing  
in the classroom. (We have more roles than those in our application.)


Ken


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Quick question regarding $_SESSION and header()

2008-12-11 Thread Dan Joseph
On Thu, Dec 11, 2008 at 2:01 PM, Ólafur Waage  wrote:

> I should be able to set a session var and then do a header redirect
> right? Small bug regarding that and i just need to be sure.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Yep, what "bug" are you running into?  Remember you have session_start() on
the next page for it to be there.

-- 
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."


Re: [PHP] Foreign Keys Question

2008-12-11 Thread Robert Cummings
On Thu, 2008-12-11 at 13:46 -0500, tedd wrote:
> At 12:29 PM -0600 12/11/08, phphelp -- kbk wrote:
> >Hey tedd ---
> >
> >Do I understand your structure correctly that you have something like:
> >
> >Courses (table)
> >course_id,
> >subject_id,
> >student1_id,
> >student2_id,
> >student3_id,
> >student4_id,
> >
> >
> >Is that right?
> >
> >Ken
> 
> Ken:
> 
> That was right, but I think I've reconsidered.
> 
> You see, Richard pointed out the error of my ways, namely:
> 
> Student table has student data and ID -- as may records as there are students.
> 
> Instructor table has instructor data and ID -- as may records as 
> there are instructors.
> 
> Course table has course data, ID and Instructor ID and Student ID -- 
> but the number of records vary.
> 
> While there will be only one record per Instructor and one pre 
> Student, the Course table can have up to four records for each course 
> depending upon actuall attendance.
> 
> I think that makes more sense.

Student attendance should be a table with rows for each student in
attendance. If you want to limit the number make a check before adding
another student. Don't hard code the number via fields like above or
you'll find it overly ugly to add/remove students or even increase the
number of allowed students. As it stands to allow 6 students you would
have to add 2 more columns. With attendance controled by a table with a
row for ewach attendance you would only need to update a configuration
variable the determines the maximim number of allowed students in
attendance.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Quick question regarding $_SESSION and header()

2008-12-11 Thread Ólafur Waage
I should be able to set a session var and then do a header redirect
right? Small bug regarding that and i just need to be sure.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Foreign Keys Question

2008-12-11 Thread tedd

At 1:48 PM -0500 12/11/08, Robert Cummings wrote:

On Thu, 2008-12-11 at 13:27 -0500, Bastien Koert wrote:
 > On Thu, Dec 11, 2008 at 12:56 PM, tedd 

 > > Does anyone have any example code to show me the actual syntax?

 > Joins should allow you to pull the data from the table in one query

You want to be careful using joins though. If you were to pull all that
data in one shot using joins you would create a large data transfer
mostly containing redundant data.

Cheers,
Rob.


Rob:

Good point. Maybe my old way of doing that was the best. Simply get 
the ID's needed from one table and then open the necessary tables 
accordingly. In other words, stop worrying about the number of times 
I'm going to the store to buy things because going once might result 
in the things being too heavy for me to carry home -- if that makes 
sense.


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Foreign Keys Question

2008-12-11 Thread Robert Cummings
On Thu, 2008-12-11 at 13:27 -0500, Bastien Koert wrote:
> On Thu, Dec 11, 2008 at 12:56 PM, tedd  
> >
> > I believe I can create the Course table (excluding everything not germane)
> > like so:
> >
> > INDEX (student_id),
> > FOREIGN KEY (student_id)
> >   REFERENCES (students(id)),
> > INDEX (instructor_id),
> > FOREIGN KEY (instructor_id)
> >   REFERENCES (instructors(id)),
> >
> > But how do I use Foreign Keys to retrieve data? What is the specific query
> > to pull out data from all three tables at once?
> >
> > Does anyone have any example code to show me the actual syntax?

> Nope, You can't use Fks for this. Foreign keys are constraints and are used
> to limit the data in the table. If you were to put an FK on the courses
> table referencing the instructors table on the instructor id, the instructor
> id must exist in the instructor table before db will allow the entry of the
> instructor id in the courses table. The idea is to force data integrity in a
> system such that certain records can't be created without having
> the necessary backup data from another table.
> Joins should allow you to pull the data from the table in one query

You want to be careful using joins though. If you were to pull all that
data in one shot using joins you would create a large data transfer
mostly containing redundant data.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Foreign Keys Question

2008-12-11 Thread tedd

At 12:29 PM -0600 12/11/08, phphelp -- kbk wrote:

Hey tedd ---

Do I understand your structure correctly that you have something like:

Courses (table)
course_id,
subject_id,
student1_id,
student2_id,
student3_id,
student4_id,


Is that right?

Ken


Ken:

That was right, but I think I've reconsidered.

You see, Richard pointed out the error of my ways, namely:

Student table has student data and ID -- as may records as there are students.

Instructor table has instructor data and ID -- as may records as 
there are instructors.


Course table has course data, ID and Instructor ID and Student ID -- 
but the number of records vary.


While there will be only one record per Instructor and one pre 
Student, the Course table can have up to four records for each course 
depending upon actuall attendance.


I think that makes more sense.

As for my "Foreign Keys Question", I think the answer is that it 
enforces rules upon the configuration (i.e., deleting, altering, and 
such), but does not provide any significant service beyond that.


Cheers,

tedd


--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PECL JSON package

2008-12-11 Thread Phil Ewington - iModel

Eric Butera wrote:

On Thu, Dec 11, 2008 at 5:43 AM, Phil Ewington - iModel
 wrote:
  

Phil Ewington - iModel wrote:


Hi All,

I have just installed the PECL JSON package, or at least think I have!!
But how do I use it?? I was expecting /usr/share/pear/Services/JSON.php to
be found on my system for include but not so. My system tells me I have
1.2.1 successfully installed but I cannot find any docs that tell me how to
make use of it. I am running PHP 5.1.6 at present.

TIA

Phil.

  

OK, seems I am confusing PECL and PEAR. Have now configured extension using
phpize and enabled in php.ini.

- Phil.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php





If you're using the pecl version, it is json_encode().

If you're using the pear version you say
require_once 'Services/JSON.php';
$json = new Services_JSON();
$output = $json->encode($value);

If you're using php5, you should have json in the build unless it was
disabled for some reason.  If you're going to be using it a lot,
you're really going to want the speed of the c version.

  
Yeah thanks. I am using the PECL version and have it compiled as an 
extension now working fine, just got confused with installing PEAR 
scripts. I have PHP 5.1.6, JSON only available in build from 5.2.0 I 
believe.


- Phil.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Foreign Keys Question

2008-12-11 Thread phphelp -- kbk

Hey tedd ---

Do I understand your structure correctly that you have something like:

Courses (table)
course_id,
subject_id,
student1_id,
student2_id,
student3_id,
student4_id,


Is that right?

Ken



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Foreign Keys Question

2008-12-11 Thread Bastien Koert
On Thu, Dec 11, 2008 at 12:56 PM, tedd  wrote:

> Hi gang:
>
> I know this is a MySQL question, but I get a better reply from this group
> than the MySQL list (no offense meant to that list) -- In any event, here
> goes.
>
> I currently have a project that's a classic example of a relational
> database, namely the course, student, and instructor problem.
>
> I have my database set-up such that there are tables for courses, students,
> and instructors -- each table with it's own unique/primary ID.
>
> The Course table has a field for the Instructor, which is the primary ID
> found in the Instructor's table.
>
> Likewise, the Course table also has fields for up-to four students (a
> private tutorial service). These will be filled by the the respective
> primary ID's found in the Student's table.
>
> This configuration is "Second Normal Form".
>
> The Course table also has fields for date, times and such.
>
> If I want to see the schedule for any specific day, I simply open the
> Course table and search for date and time. From that I can retrieve the
> Student ID's and the Instructor ID.
>
> From those, I open the Student table and pull out all students who attend
> the class and then open the Instructor's table and pull out what data I need
> re the Instructor.
>
> Everything works.
>
> My question is, can using Foreign Keys make this work better? Can I
> retrieve all this data in one query? (I think that's what foreign keys do --
> but, I'm assuming that).
>
> I believe I can create the Course table (excluding everything not germane)
> like so:
>
> INDEX (student_id),
> FOREIGN KEY (student_id)
>   REFERENCES (students(id)),
> INDEX (instructor_id),
> FOREIGN KEY (instructor_id)
>   REFERENCES (instructors(id)),
>
> But how do I use Foreign Keys to retrieve data? What is the specific query
> to pull out data from all three tables at once?
>
> Does anyone have any example code to show me the actual syntax?
>
> Thanks and Cheers,
>
> tedd
>
> --
> ---
> http://sperling.com  http://ancientstones.com  http://earthstones.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
Nope, You can't use Fks for this. Foreign keys are constraints and are used
to limit the data in the table. If you were to put an FK on the courses
table referencing the instructors table on the instructor id, the instructor
id must exist in the instructor table before db will allow the entry of the
instructor id in the courses table. The idea is to force data integrity in a
system such that certain records can't be created without having
the necessary backup data from another table.
Joins should allow you to pull the data from the table in one query

hth

-- 

Bastien

Cat, the other other white meat


Re: [PHP] how to not show login info in the url ...what am I looking for?

2008-12-11 Thread tedd

At 11:23 AM -0500 12/11/08, Robert Cummings wrote:

On Thu, 2008-12-11 at 11:05 -0500, tedd wrote:
 > When I say "Hack a site" I mean to do something to get the site to

 provide an unintended result as  expected by the author.

 Much like using CSS "Hacks" to get browsers to do something that was
 not intended by the original designers.

 On the other hand, my understanding of "cracking" means to "crack"
 some type of encryption. Thus, the reason why I did not say "cracking
 the site" instead of "hacking the site".


Cracking is not just about encryption. It's about bypassing any kind of
measure put in place to prevent someone from doing something. Hacking on
the other hand does not embody this principle, although hacking may be
employed to achieve cracking. Just because pop culture is completely
ignorant to the difference, doesn't mean you as a member of the
community need to jump on board and bleat like a sheep. If you intend to
misuse hacker, then you should at least provide more detail such as
white-, grey-, or black-hat.

Cheers,
Rob.



Okay, I shall adjust my fracking terminology. :-)

Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Foreign Keys Question

2008-12-11 Thread tedd

Hi gang:

I know this is a MySQL question, but I get a better reply from this 
group than the MySQL list (no offense meant to that list) -- In any 
event, here goes.


I currently have a project that's a classic example of a relational 
database, namely the course, student, and instructor problem.


I have my database set-up such that there are tables for courses, 
students, and instructors -- each table with it's own unique/primary 
ID.


The Course table has a field for the Instructor, which is the primary 
ID found in the Instructor's table.


Likewise, the Course table also has fields for up-to four students (a 
private tutorial service). These will be filled by the the respective 
primary ID's found in the Student's table.


This configuration is "Second Normal Form".

The Course table also has fields for date, times and such.

If I want to see the schedule for any specific day, I simply open the 
Course table and search for date and time. From that I can retrieve 
the Student ID's and the Instructor ID.


From those, I open the Student table and pull out all students who 
attend the class and then open the Instructor's table and pull out 
what data I need re the Instructor.


Everything works.

My question is, can using Foreign Keys make this work better? Can I 
retrieve all this data in one query? (I think that's what foreign 
keys do -- but, I'm assuming that).


I believe I can create the Course table (excluding everything not 
germane) like so:


INDEX (student_id),
FOREIGN KEY (student_id)
   REFERENCES (students(id)),
INDEX (instructor_id),
FOREIGN KEY (instructor_id)
   REFERENCES (instructors(id)),

But how do I use Foreign Keys to retrieve data? What is the specific 
query to pull out data from all three tables at once?


Does anyone have any example code to show me the actual syntax?

Thanks and Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Poll of Sorts: Application Frameworks--Zend, Cake etc

2008-12-11 Thread Eric Butera
On Thu, Dec 11, 2008 at 12:12 PM, Nathan Nobbe <[EMAIL PROTECTED]> wrote:
>
> On Thu, Dec 11, 2008 at 8:25 AM, Eric Butera <[EMAIL PROTECTED]> wrote:
>>
>> On Thu, Dec 11, 2008 at 10:22 AM, Bastien Koert <[EMAIL PROTECTED]> wrote:
>> >
>> >
>> > On Thu, Dec 11, 2008 at 10:15 AM, Eric Butera <[EMAIL PROTECTED]>
>> > wrote:
>> >>
>> >> On Thu, Dec 11, 2008 at 9:56 AM, Terion Miller
>> >> <[EMAIL PROTECTED]>
>> >> wrote:
>> >> > Hey Everyone, I am wondering if using a framework such as one of
>> >> > these
>> >> > may
>> >> > make my life easier, which do any of you use and what has been your
>> >> > experience with the learning curve of them?
>> >> > I just put Cake on my local server, basically I want to know which is
>> >> > easiest? LOL...
>> >> > Terion
>> >> >
>> >>
>> >> Define easiest.  What is it that you need to code?  If you mean cookie
>> >> cutter sites that have been done a million times with minimal
>> >> flexibility... :)  I'm in the same boat as you though.  I don't know
>> >> which one meets the needs I have the best.  There's stuff like cake
>> >> which is really easy to start up, then there's stuff like symphony
>> >> that will let you do anything, but you really have to work at it.
>> >>
>> >> --
>> >> PHP General Mailing List (http://www.php.net/)
>> >> To unsubscribe, visit: http://www.php.net/unsub.php
>> >>
>> >
>> > There are definite learning curves when picking these up.
>> >
>> > symfony and ZF have the largest because they either do more (symfony) or
>> > are
>> > designed to be used piecemeal (ZF)
>> >
>> > CodeIgnitor is one of the easiest ones to start using with Cake not far
>> > behind
>> >
>> > --
>> >
>> > Bastien
>> >
>> > Cat, the other other white meat
>> >
>>
>> One huge part of this that I didn't mention before is the community
>> around the frameworks too.  Do they have good docs, examples, stuff
>> like that.  Can you ask questions and get quality answers?
>
> i also take performance into consideration.  heres a comparison between some
> of the aforementioned frameworks,
>
> http://www.avnetlabs.com/php/php-framework-comparison-benchmarks
>
> -nathan
>
>

Here's another

http://www.yiiframework.com/performance/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Poll of Sorts: Application Frameworks--Zend, Cake etc

2008-12-11 Thread Nathan Nobbe
On Thu, Dec 11, 2008 at 8:25 AM, Eric Butera <[EMAIL PROTECTED]> wrote:

> On Thu, Dec 11, 2008 at 10:22 AM, Bastien Koert <[EMAIL PROTECTED]> wrote:
> >
> >
> > On Thu, Dec 11, 2008 at 10:15 AM, Eric Butera <[EMAIL PROTECTED]>
> wrote:
> >>
> >> On Thu, Dec 11, 2008 at 9:56 AM, Terion Miller <[EMAIL PROTECTED]
> >
> >> wrote:
> >> > Hey Everyone, I am wondering if using a framework such as one of these
> >> > may
> >> > make my life easier, which do any of you use and what has been your
> >> > experience with the learning curve of them?
> >> > I just put Cake on my local server, basically I want to know which is
> >> > easiest? LOL...
> >> > Terion
> >> >
> >>
> >> Define easiest.  What is it that you need to code?  If you mean cookie
> >> cutter sites that have been done a million times with minimal
> >> flexibility... :)  I'm in the same boat as you though.  I don't know
> >> which one meets the needs I have the best.  There's stuff like cake
> >> which is really easy to start up, then there's stuff like symphony
> >> that will let you do anything, but you really have to work at it.
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >
> > There are definite learning curves when picking these up.
> >
> > symfony and ZF have the largest because they either do more (symfony) or
> are
> > designed to be used piecemeal (ZF)
> >
> > CodeIgnitor is one of the easiest ones to start using with Cake not far
> > behind
> >
> > --
> >
> > Bastien
> >
> > Cat, the other other white meat
> >
>
> One huge part of this that I didn't mention before is the community
> around the frameworks too.  Do they have good docs, examples, stuff
> like that.  Can you ask questions and get quality answers?


i also take performance into consideration.  heres a comparison between some
of the aforementioned frameworks,

http://www.avnetlabs.com/php/php-framework-comparison-benchmarks

-nathan


Re: [PHP] how to not show login info in the url ...what am I looking for?

2008-12-11 Thread Robert Cummings
On Thu, 2008-12-11 at 11:05 -0500, tedd wrote:
> At 10:12 AM -0500 12/10/08, APseudoUtopia wrote:
> >On Wed, Dec 10, 2008 at 10:03 AM, tedd <[EMAIL PROTECTED]> wrote:
> >  > In my mind, hacking a site (without doing damage) is a good introduction 
> > to
> >  > a client.
> >>
> >
> >*Ahem*You mean 'cracking'? :-P
> 
> 
> *Ahem*... You mean to stick your tongue out at me? That's one 
> definitions of using :-P
> 
> You see, there's all sorts of definitions for everything.
> 
> When I say "Hack a site" I mean to do something to get the site to 
> provide an unintended result as  expected by the author.
> 
> Much like using CSS "Hacks" to get browsers to do something that was 
> not intended by the original designers.
> 
> On the other hand, my understanding of "cracking" means to "crack" 
> some type of encryption. Thus, the reason why I did not say "cracking 
> the site" instead of "hacking the site".

Cracking is not just about encryption. It's about bypassing any kind of
measure put in place to prevent someone from doing something. Hacking on
the other hand does not embody this principle, although hacking may be
employed to achieve cracking. Just because pop culture is completely
ignorant to the difference, doesn't mean you as a member of the
community need to jump on board and bleat like a sheep. If you intend to
misuse hacker, then you should at least provide more detail such as
white-, grey-, or black-hat.

Cheers,
Rob.
-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] how to not show login info in the url ...what am I looking for?

2008-12-11 Thread Stut

On 11 Dec 2008, at 16:05, tedd wrote:

At 10:12 AM -0500 12/10/08, APseudoUtopia wrote:
On Wed, Dec 10, 2008 at 10:03 AM, tedd <[EMAIL PROTECTED]>  
wrote:
> In my mind, hacking a site (without doing damage) is a good  
introduction to

> a client.




*Ahem*You mean 'cracking'? :-P



*Ahem*... You mean to stick your tongue out at me? That's one  
definitions of using :-P


You see, there's all sorts of definitions for everything.

When I say "Hack a site" I mean to do something to get the site to  
provide an unintended result as  expected by the author.


Much like using CSS "Hacks" to get browsers to do something that was  
not intended by the original designers.


On the other hand, my understanding of "cracking" means to "crack"  
some type of encryption. Thus, the reason why I did not say  
"cracking the site" instead of "hacking the site".


Hacking: Getting something to do something it was not designed to do.

Cracking: Getting something to do something it was specifically  
designed to prevent.


IMHO.

-Stut

--
http://stut.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] how to not show login info in the url ...what am I looking for?

2008-12-11 Thread tedd

At 10:12 AM -0500 12/10/08, APseudoUtopia wrote:

On Wed, Dec 10, 2008 at 10:03 AM, tedd <[EMAIL PROTECTED]> wrote:
 > In my mind, hacking a site (without doing damage) is a good introduction to
 > a client.




*Ahem*You mean 'cracking'? :-P



*Ahem*... You mean to stick your tongue out at me? That's one 
definitions of using :-P


You see, there's all sorts of definitions for everything.

When I say "Hack a site" I mean to do something to get the site to 
provide an unintended result as  expected by the author.


Much like using CSS "Hacks" to get browsers to do something that was 
not intended by the original designers.


On the other hand, my understanding of "cracking" means to "crack" 
some type of encryption. Thus, the reason why I did not say "cracking 
the site" instead of "hacking the site".


Cheers,

tedd

--
---
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Poll of Sorts: Application Frameworks--Zend, Cake etc

2008-12-11 Thread Eric Butera
On Thu, Dec 11, 2008 at 10:22 AM, Bastien Koert <[EMAIL PROTECTED]> wrote:
>
>
> On Thu, Dec 11, 2008 at 10:15 AM, Eric Butera <[EMAIL PROTECTED]> wrote:
>>
>> On Thu, Dec 11, 2008 at 9:56 AM, Terion Miller <[EMAIL PROTECTED]>
>> wrote:
>> > Hey Everyone, I am wondering if using a framework such as one of these
>> > may
>> > make my life easier, which do any of you use and what has been your
>> > experience with the learning curve of them?
>> > I just put Cake on my local server, basically I want to know which is
>> > easiest? LOL...
>> > Terion
>> >
>>
>> Define easiest.  What is it that you need to code?  If you mean cookie
>> cutter sites that have been done a million times with minimal
>> flexibility... :)  I'm in the same boat as you though.  I don't know
>> which one meets the needs I have the best.  There's stuff like cake
>> which is really easy to start up, then there's stuff like symphony
>> that will let you do anything, but you really have to work at it.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>
> There are definite learning curves when picking these up.
>
> symfony and ZF have the largest because they either do more (symfony) or are
> designed to be used piecemeal (ZF)
>
> CodeIgnitor is one of the easiest ones to start using with Cake not far
> behind
>
> --
>
> Bastien
>
> Cat, the other other white meat
>

One huge part of this that I didn't mention before is the community
around the frameworks too.  Do they have good docs, examples, stuff
like that.  Can you ask questions and get quality answers?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Poll of Sorts: Application Frameworks--Zend, Cake etc

2008-12-11 Thread Terion Miller
On Thu, Dec 11, 2008 at 9:22 AM, Bastien Koert <[EMAIL PROTECTED]> wrote:

>
>
> On Thu, Dec 11, 2008 at 10:15 AM, Eric Butera <[EMAIL PROTECTED]>wrote:
>
>> On Thu, Dec 11, 2008 at 9:56 AM, Terion Miller <[EMAIL PROTECTED]>
>> wrote:
>> > Hey Everyone, I am wondering if using a framework such as one of these
>> may
>> > make my life easier, which do any of you use and what has been your
>> > experience with the learning curve of them?
>> > I just put Cake on my local server, basically I want to know which is
>> > easiest? LOL...
>> > Terion
>> >
>>
>> Define easiest.  What is it that you need to code?  If you mean cookie
>> cutter sites that have been done a million times with minimal
>> flexibility... :)  I'm in the same boat as you though.  I don't know
>> which one meets the needs I have the best.  There's stuff like cake
>> which is really easy to start up, then there's stuff like symphony
>> that will let you do anything, but you really have to work at it.
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
> There are definite learning curves when picking these up.
>
> symfony and ZF have the largest because they either do more (symfony) or
> are designed to be used piecemeal (ZF)
>
> CodeIgnitor is one of the easiest ones to start using with Cake not far
> behind
>
> --
>
> Bastien
>
> Cat, the other other white meat
>


I'll have to  check out CodeIgnitor, I can say that with my limited ability
I have set up Cake and made a db connection within 10 mins, and I'm not
entirely confused and frustrated yet so thats a good sign ...lol
terion


Re: [PHP] Poll of Sorts: Application Frameworks--Zend, Cake etc

2008-12-11 Thread Bastien Koert
On Thu, Dec 11, 2008 at 10:15 AM, Eric Butera <[EMAIL PROTECTED]> wrote:

> On Thu, Dec 11, 2008 at 9:56 AM, Terion Miller <[EMAIL PROTECTED]>
> wrote:
> > Hey Everyone, I am wondering if using a framework such as one of these
> may
> > make my life easier, which do any of you use and what has been your
> > experience with the learning curve of them?
> > I just put Cake on my local server, basically I want to know which is
> > easiest? LOL...
> > Terion
> >
>
> Define easiest.  What is it that you need to code?  If you mean cookie
> cutter sites that have been done a million times with minimal
> flexibility... :)  I'm in the same boat as you though.  I don't know
> which one meets the needs I have the best.  There's stuff like cake
> which is really easy to start up, then there's stuff like symphony
> that will let you do anything, but you really have to work at it.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
There are definite learning curves when picking these up.

symfony and ZF have the largest because they either do more (symfony) or are
designed to be used piecemeal (ZF)

CodeIgnitor is one of the easiest ones to start using with Cake not far
behind

-- 

Bastien

Cat, the other other white meat


Re: [PHP] Can GD make a JPG thumbnail of a PDF?

2008-12-11 Thread ceo

If system("convert -version") does nothing, it is probably erroring out.



Mess around with exec and using 2>&1 to try to get the error message.



It's going to boil down to paths and permissions.



The PHP user probably doesn't have convert in $PATH.



Use a FULL PATH for system/exec calls for *any* path, and within *any* script 
being called.



Anything else is just a time bomb waiting to blow up on you.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Poll of Sorts: Application Frameworks--Zend, Cake etc

2008-12-11 Thread Eric Butera
On Thu, Dec 11, 2008 at 9:56 AM, Terion Miller <[EMAIL PROTECTED]> wrote:
> Hey Everyone, I am wondering if using a framework such as one of these may
> make my life easier, which do any of you use and what has been your
> experience with the learning curve of them?
> I just put Cake on my local server, basically I want to know which is
> easiest? LOL...
> Terion
>

Define easiest.  What is it that you need to code?  If you mean cookie
cutter sites that have been done a million times with minimal
flexibility... :)  I'm in the same boat as you though.  I don't know
which one meets the needs I have the best.  There's stuff like cake
which is really easy to start up, then there's stuff like symphony
that will let you do anything, but you really have to work at it.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Poll of Sorts: Application Frameworks--Zend, Cake etc

2008-12-11 Thread Terion Miller
Hey Everyone, I am wondering if using a framework such as one of these may
make my life easier, which do any of you use and what has been your
experience with the learning curve of them?
I just put Cake on my local server, basically I want to know which is
easiest? LOL...
Terion


Re: [PHP] PECL JSON package

2008-12-11 Thread Eric Butera
On Thu, Dec 11, 2008 at 5:43 AM, Phil Ewington - iModel
<[EMAIL PROTECTED]> wrote:
> Phil Ewington - iModel wrote:
>>
>> Hi All,
>>
>> I have just installed the PECL JSON package, or at least think I have!!
>> But how do I use it?? I was expecting /usr/share/pear/Services/JSON.php to
>> be found on my system for include but not so. My system tells me I have
>> 1.2.1 successfully installed but I cannot find any docs that tell me how to
>> make use of it. I am running PHP 5.1.6 at present.
>>
>> TIA
>>
>> Phil.
>>
> OK, seems I am confusing PECL and PEAR. Have now configured extension using
> phpize and enabled in php.ini.
>
> - Phil.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

If you're using the pecl version, it is json_encode().

If you're using the pear version you say
require_once 'Services/JSON.php';
$json = new Services_JSON();
$output = $json->encode($value);

If you're using php5, you should have json in the build unless it was
disabled for some reason.  If you're going to be using it a lot,
you're really going to want the speed of the c version.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] PECL JSON package

2008-12-11 Thread Phil Ewington - iModel

Phil Ewington - iModel wrote:

Hi All,

I have just installed the PECL JSON package, or at least think I 
have!! But how do I use it?? I was expecting 
/usr/share/pear/Services/JSON.php to be found on my system for include 
but not so. My system tells me I have 1.2.1 successfully installed but 
I cannot find any docs that tell me how to make use of it. I am 
running PHP 5.1.6 at present.


TIA

Phil.

OK, seems I am confusing PECL and PEAR. Have now configured extension 
using phpize and enabled in php.ini.


- Phil.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PECL JSON package

2008-12-11 Thread Phil Ewington - iModel

Hi All,

I have just installed the PECL JSON package, or at least think I have!! 
But how do I use it?? I was expecting /usr/share/pear/Services/JSON.php 
to be found on my system for include but not so. My system tells me I 
have 1.2.1 successfully installed but I cannot find any docs that tell 
me how to make use of it. I am running PHP 5.1.6 at present.


TIA

Phil.

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



SV: [PHP] Variable name for constants?

2008-12-11 Thread Anders Norrbring
> ... and in that way, you can create the name of the constant as you
> please:
> 
> $VAR_IMG = 'HOME';
> define('IMG_HOME', 'pic.jpg');
> echo(constant('IMG_'.$VAR_IMG));
> 
> SanTa
> 
> - Original Message -
> From: "clive" <[EMAIL PROTECTED]>
> To: "PHP LIST" 
> Sent: Thursday, December 11, 2008 9:18 AM
> Subject: Re: [PHP] Variable name for constants?
> 
> 
> >
> >> I dont think you can do that with a constant, but you can do this a
> >> normal variable:
> >>
> >
> > I stand under correction form my previous email, it can be done:
> >
> > define('TEST', 'the value of constant TEST');
> >
> > $var= 'TEST';
> >
> > echo constant($var);
> >


Ah.. Seems like I figured it out right then with the hint from Clive.. ;-)
Thanks a lot guys! I'll out this to the test a little later!

Have a great weekend,
Anders.



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



SV: [PHP] Variable name for constants?

2008-12-11 Thread Anders Norrbring

> > I dont think you can do that with a constant, but you can do this a
> > normal variable:
> >
> 
> I stand under correction form my previous email, it can be done:
> 
> define('TEST', 'the value of constant TEST');
> 
> $var= 'TEST';
> 
> echo constant($var);


This may be too early in the morning for me, but I don't get it.. ;-)

Say I have these definitions;
define("IMG_HOME", "pic1.png");
define("IMG_AWAY", "pic2.png");
define("IMG_ELSE", "pic3.png");

Then a function should present the right image based on a variable
(pseudocode):

function show($name) {
   present_img( IMG_$name );
}

If I understand right (probably not...), then I could concat and do like
this?

present_img( constant("IMG_" . $name) );





-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Variable name for constants?

2008-12-11 Thread HostWare Kft.

... and in that way, you can create the name of the constant as you please:

$VAR_IMG = 'HOME';
define('IMG_HOME', 'pic.jpg');
echo(constant('IMG_'.$VAR_IMG));

SanTa

- Original Message - 
From: "clive" <[EMAIL PROTECTED]>

To: "PHP LIST" 
Sent: Thursday, December 11, 2008 9:18 AM
Subject: Re: [PHP] Variable name for constants?




I dont think you can do that with a constant, but you can do this a 
normal variable:




I stand under correction form my previous email, it can be done:

define('TEST', 'the value of constant TEST');

$var= 'TEST';

echo constant($var);




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Variable name for constants?

2008-12-11 Thread clive


I dont think you can do that with a constant, but you can do this a 
normal variable:




I stand under correction form my previous email, it can be done:

define('TEST', 'the value of constant TEST');

$var= 'TEST';

echo constant($var);




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Variable name for constants?

2008-12-11 Thread clive

Anders Norrbring wrote:

I've been experimenting with having a varaible constant name, but failed
miserably... Can I please have a pointer?

What I'm trying to do is something like this:

$name = "home";

Then read the constant IMG_HOME, like IMG_$name, I'm not sure I make myself
understood, but I hope so..

Anders.
  


I dont think you can do that with a constant, but you can do this a 
normal variable:


$test = 'the value of test variable';
$var ='test';

echo $$var;
// will echo $test;

Clive



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Variable name for constants?

2008-12-11 Thread Anders Norrbring
I've been experimenting with having a varaible constant name, but failed
miserably... Can I please have a pointer?

What I'm trying to do is something like this:

$name = "home";

Then read the constant IMG_HOME, like IMG_$name, I'm not sure I make myself
understood, but I hope so..

Anders.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php