[PHP-DB] Re: MySQL/PHP Iterative Tree

2002-11-27 Thread David Elliott
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Greetings John

On 26 November 2002 at 18:54:04 -0500 (which was 23:54 where I live) John W.
Holmes wrote and made these points

>> This is OK for some simple trees, however it does have some limitations.
>>
>> (1) Adding another tree / series of nodes into the middle if the set.

> Not if you can define what the absolute max size of a node will be.

Most of my applications I can not, and this is a limitation that I would never
want to impose on on my apps.

If you can then good.

>> (2) A child node that belongs to more than one parent.

> I give a certain company the node numbers of 6-5006. Now assign that left
> and right pair a unique id. Now you can have multiple people with that
> same ID.

I might have misunderstood you but sorry but this is a big no no in my all
my apps. Every item must have a unique ID. This is a fundamental basis of
all my systems.

- --
 See you in Cyber space,   ___
  David   |David  Elliott|   Software Engineer|
 _| [EMAIL PROTECTED] | PGP Key ID 0x650F4534  |
| Would it help if I got out and pushed?  -Princess Leia  |

-BEGIN PGP SIGNATURE-
Version: 6.5.8ckt http://www.ipgpp.com/

iQA/AwUBPeSW6PmK8eZlD0U0EQJ+HwCg4UQSEN5ee3i5kUiiM7aBsDH0cl4AmwbM
/l5gv6cPCULmf9KUWJ46LY2a
=4Hwb
-END PGP SIGNATURE-


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




[PHP-DB] Re: MySQL/PHP Iterative Tree

2002-11-26 Thread David Elliott
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello 1LT

On 26 November 2002 at 09:54:57 -0500 (which was 14:54 where I live) 1LT
John W. Holmes emanated these words of wisdom

> You may want to check out using Nested Sets instead of a Parent-Child-ID
> system.

This is OK for some simple trees, however it does have some limitations.

(1) Adding another tree / series of nodes into the middle if the set.

(2) A child node that belongs to more than one parent.

- --
 Cheers,   ___
  David   |    David  Elliott|   Software Engineer|
 _| [EMAIL PROTECTED] | PGP Key ID 0x650F4534  |
| Mathematicians DO IT with sum.  |

-BEGIN PGP SIGNATURE-
Version: 6.5.8ckt http://www.ipgpp.com/

iQA/AwUBPeOcYPmK8eZlD0U0EQJRVACfXZGjwwUlKOV1yEvtEf96D0MdNakAnAuF
PBlwh2HSenDKSVvldLp8H3fb
=QE8q
-END PGP SIGNATURE-


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




[PHP-DB] Re: MySQL/PHP Iterative Tree

2002-11-26 Thread David Elliott
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello Adam

On 26 November 2002 at 08:25:22 -0500 (which was 13:25 where I live) Adam
Voigt emanated these words of wisdom

< ... >

> Ok, and I am using this structure to make a kind of drill down
> structure, so the top level would be where parentid = '0', then
> you take those id's and select from this table where parentid is
> equal to those id's, and now your starting to navigate through
> the tree, and so on.

> Now, the real question, I have found a Javascript menu script which
> will let users of the site click on it, and then click on the submenu
> and down and down through all the level's that might dynamically exist,

Be careful of the size and the time it takes to build a big tree.

> but I can't for the life of me figure out how to recursively get the
> name and id for each row (which is what I need to build the menu and
> make link's out of each item), for as many sublevel's as there might be
> (infinite). Am I missing something, is there a simple logical way to do
> this recursively? Or if there's a semi-complex way, anyone got a script
> example? I'd very much appreciate it.

This is not much help but have done something like that in MSSQL with stored
procedure (about 120 to 150 lines of SQL).

The logic went something like.

get all top level
put into a temptable_1
go through temptable_1
  put line into temptable_2 noting level
  add on any children for line into temptable_2
next line of temptable_1
copy temptable_2 to temptable_1
keep going through temptable_1 until there is no more children at last level

I also used a separate table for the links this way it is easier to go both
up and down the tree.

What would be nice is to do it dynamically and display only the tree that
you need and just get the data for the children when needed. eg like MSDSon
M$ site

- --
 TTFN,         ___
  David   |David  Elliott|   Software Engineer|
 _| [EMAIL PROTECTED] | PGP Key ID 0x650F4534  |
| I am Barney of Borg...Sesame Street will be assimilated.|

-BEGIN PGP SIGNATURE-
Version: 6.5.8ckt http://www.ipgpp.com/

iQA/AwUBPeOIC/mK8eZlD0U0EQI8YQCdEKtpYBkVNmLGYEs2xt3RKBoh1A0An2FG
KzmAxhrABe/7JZxw3mvmYkaJ
=xdTm
-END PGP SIGNATURE-


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




[PHP-DB] Re: regarding multiple joins

2002-11-22 Thread David Elliott
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Greetings Jonathan

On 22 November 2002 at 01:55:10 -0800 (which was 09:55 where I live)
Jonathan Narong graced us with these comments

> i have an table 'articles' which has multiple fields, such as author,
> editor, photographer, etc.. each of these fields contains an index number
> which relates to another table 'people' that lists everyone. basically i
> just want to select  everything with the names displaying, instead of id
> numbers.

not sure exactly what you want.

I have a table called country. It contains all ID's.The name of which is in
an item table, so it has to use the item table a number of time so that it
can display just names to the user and not ID's

== One I made earlier =
select
  a.ItemId CID
  ,b.name country
  ,c.name Currency
  ,d.name Region
  ,e.name VAT
  ,f.name Delivery
from
  country a
  ,item b
  ,item c
  ,item d
  ,item e
  ,item f
where
  a.itemid = b.itemid
  and a.CurrId = c.itemid
  and a.GeoRegId = d.itemid
  and a.VaTID = e.itemid
  and a.DelID = f.itemid
order by f.name
== One I made earlier =

HTH

- --
 Best regards, _______
  David   |David  Elliott|   Software Engineer|
 _| [EMAIL PROTECTED] | PGP Key ID 0x650F4534  |
| "It should be a while...he's very thorough." -- Trapper on Hawkeye  |

-BEGIN PGP SIGNATURE-
Version: 6.5.8ckt http://www.ipgpp.com/

iQA+AwUBPd4EYvmK8eZlD0U0EQLBuwCWJZVbOfWxqmMd+4KgqKmIgRs3agCggA2g
qzjRbhBT9szMn6EJI4lHZhE=
=e0St
-END PGP SIGNATURE-


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




[PHP-DB] Re: Get Last ID Inserted

2002-11-22 Thread David Elliott
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Greetings Adam

On 21 November 2002 at 11:12:46 -0500 (which was 16:12 where I live) Adam
Voigt emanated these words of wisdom

> But if there are heavy operations on the site, will this not also pick
> up a different last inserted id, if in the split milisecond between the
> insert and the next mssql_query which has the @@identity say, another
> user does an insert?

No unless you drop the connection, but then it should give you a NULL. To
quote M$

==8<=

Remarks

IDENT_CURRENT is similar to the Microsoft® SQL Server™ 2000 identity
functions SCOPE_IDENTITY and @@IDENTITY. All three functions return
last-generated identity values. However, the scope and session on which
'last' is defined in each of these functions differ.

IDENT_CURRENT returns the last identity value generated for a specific table
in any session and any scope.

@@IDENTITY returns the last identity value generated for any table in the
current session, across all scopes.

SCOPE_IDENTITY returns the last identity value generated for any table in
the current session and the current scope.

==8<=

- --
 Ti2GO,___
  David       |David  Elliott|   Software Engineer|
 _| [EMAIL PROTECTED] | PGP Key ID 0x650F4534  |
| I didn't do it!  Nobody saw me do it!  You can't prove anything!|

-BEGIN PGP SIGNATURE-
Version: 6.5.8ckt http://www.ipgpp.com/

iQA/AwUBPd3zufmK8eZlD0U0EQJ37QCglnr+5j0h7CSOG39qznRq2F8fZNIAn10R
xhMTzYhlrvim4iyzB0rny48J
=DtzT
-END PGP SIGNATURE-


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




[PHP-DB] Re: Get Last ID Inserted

2002-11-21 Thread David Elliott
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello Adam

On 21 November 2002 at 11:12:46 -0500 (which was 16:12 where I live) Adam
Voigt rearranged electrons to get

> But if there are heavy operations on the site, will this not also pick
> up a different last inserted id, if in the split milisecond between the
> insert and the next mssql_query which has the @@identity say, another
> user does an insert?

No. It picks up the last identity on that connection. So it does not mater
how many other connections and what they are doing.

It can only be wrong if you close off the connection and open another one.
The other way is to put it all into one SQL statement (as long as you don't
use mssql_? functions in PHP)

e.g. (one I used earlier)

==8<=
begin transaction

set nocount on

declare
  @NewId int

update item
set name = 'Canada Delivery'
where itemid = '428'

insert into item
(ItemTypeId, Name, LastUpdated)
values
(49,'Mexico Delivery',getutcdate())

set @NewId = @@identity

insert into DelArea
(itemid,StdEUR, StdGBP, StdUSD, HotEUR, HotGBP, HotUSD)
values
(@NewId,37,19,45,134,70,70)

Update country
set DelId = @NewId
where itemid = 288

commit

select
  @NewId NewDelId

==8<=



- --
 Ti2GO,___________
  David   |David  Elliott|   Software Engineer|
 _| [EMAIL PROTECTED] | PGP Key ID 0x650F4534  |
| Do you think someone was BORGED when they made these up?|

-BEGIN PGP SIGNATURE-
Version: 6.5.8ckt http://www.ipgpp.com/

iQA/AwUBPd0TBPmK8eZlD0U0EQL1awCgmS57QwyvS+bz02XsLQtwJOSGSB8AoLmo
I9VdgNIsp3GXkzWAX6I1jYpp
=UXBQ
-END PGP SIGNATURE-


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




[PHP-DB] Re: Get Last ID Inserted

2002-11-21 Thread David Elliott
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hello Adam

On 21 November 2002 at 10:47:15 -0500 (which was 15:47 where I live) Adam
Voigt wrote

> Using Microsoft SQL does anyone know how to get the id of the row that
> you just inserted without clumsily trying to select the id back based on
> the same criteria of your insert (which might be overlapping)?

select @@identity

- --
 Cheers,   ___
  David   |    David  Elliott|   Software Engineer|
 _| [EMAIL PROTECTED] | PGP Key ID 0x650F4534  |
| No dinner with Mel Gibson?! - Dot Warner|

-BEGIN PGP SIGNATURE-
Version: 6.5.8ckt http://www.ipgpp.com/

iQA/AwUBPd0DwfmK8eZlD0U0EQI3fACgsv52o5AvhuroJIVYblYXTnkiDZYAn2Ao
y1AeA+bR4KPOwZhZTAa2x7kr
=f/lr
-END PGP SIGNATURE-


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