Ben bağlantılı dört tablo var.
images
Tablo
cid link
=======================
1 something.jpg
2 else.jpg
terms
Tablo
cid term is_attr
================================
1 Location 0
2 Caption 1
3 Camera Lens 0
tags
Tablo
cid Name term_id
==============================
1 somewhere 1
2 BFE 1
3 A word 2
linked_tags
Tablo
cid photo_id tag_id
==========================
1 1 1
2 1 2
3 1 3
Bir Dönem is_attr == 1
görüntü sadece o dönem için linked_tags
tablosunda bir giriş olmalıdır eğer.
Ben resim tablosunu sorgulamak ve aynı zamanda etiketleri almak için olsaydı, ben bunu nasıl yaparım?
Ben (bir şey) var istiyorum bu döndürdü:
_____________________________________________________________________________
cid |link |attributes |tags |
=========|==================|==================|====================|
1 |something.jpg |__________________|____________________|
| ||term |value |||term |value ||
| ||========|=======|||========|=========||
| ||caption |A word |||Location|somewhere||
| || | |||Location|BFE ||
Bu benim (PHP tarafında) arıyorum budur:
//Row 1
array(
'link' => "something.jpg",
'attributes' => array('caption'=>"A word"),
'tags' => array('Location'=>array('somewhere','BFE'))
);
//Notice 'caption' points to a string and 'location' points to an array
//Row 2
array(
'link' => "else.jpg",
'attributes' => array(),
'tags' => array()
);
// OR
array(
'link' => "else.jpg"
);
// OR
array(
'link' => "else.jpg",
'attributes' => array('caption'=>""),
'tags' => array();
);