Announcement

#1 2013-10-15 18:25:30

mcl
Member
2012-11-22
30

API 'pwg.tags.getImages' and Sorting

Hello,

I am hoping someone can point me in the right direction

I am using `pwg.tags.getImages` with the following parameters on a piwigo.com hosted site

`mysite.piwigo.com/ws.php?
format=php&method=pwg.tags.getImages&tag_id[]=54&tag_id[]=492&tag_id[]=223&order=tag_id`

It returns all matching images, but the order is not sorted by `tag_id`

It returns TAG Ids in the following order splitting the images for `tag_id 54`

`54(Qty 4)
223 (Qty 5)
54 (Qty 3)
292 (Qty 7)`

I have used other combinations of Tags and I get a similar result.

It does not seem to make any difference, whether I add sort order or not.  Although I am not sure I am using the correct fieldname(tag_id) for the sort order.

Can anyone help with how I may retrieve the images, without splitting `tag_id 54` ?

Thanks

mcl

Offline

 

#2 2013-10-15 18:31:11

mistic100
Former Piwigo Team
Lyon (FR)
2008-09-27
3277

Re: API 'pwg.tags.getImages' and Sorting

hello

you can't sort by tag id, only by fields of the 'images' table ('id', 'file', 'name', 'hit', 'rating_score', 'date_creation', 'date_available') and 'rand'

you can open a ticket in the bug tracker, but honestly it would need to rewrite a big part of this api method

Offline

 

#3 2013-10-15 23:17:32

mcl
Member
2012-11-22
30

Re: API 'pwg.tags.getImages' and Sorting

Thanks for that info

As an aside if I put `id` as the sort field I get the following.

`
Warning: [mysql error 1064] You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id' at line 8
SELECT id
  FROM images i
    INNER JOIN image_category ic ON id=ic.image_id
    INNER JOIN image_tag it ON id=it.image_id
    WHERE tag_id IN (54,223,492)
  AND (category_id NOT IN (3,4,5,6,8,9,11,17,18,173))
  GROUP BY id
id  in /home/sys/var/www/piwigo_master_25/include/dblayer/functions_mysqli.inc.php on line 834
Fatal error: Call to a member function fetch_assoc() on a non-object in /home/sys/var/www/piwigo_master_25/include/dblayer/functions_mysqli.inc.php on line 181
`

If I put `name` as the sort field it fails as above except for `name` in place of the line 834 error

If I put rank it works but still splits tags

Thanks

mcl

Offline

 

Board footer

Powered by FluxBB

github twitter newsletter Donate Piwigo.org © 2002-2024 · Contact