Sample script of Coppermine database query, output format with CPG ? Sample script of Coppermine database query, output format with CPG ?
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Sample script of Coppermine database query, output format with CPG ?

Started by florennes-as.be, June 02, 2007, 10:21:40 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

florennes-as.be

Hello all !

  Is there a sample script of database query, output format of datas to be found easily, and to learn ?
  I do not have found as far as now ... And i think this can be helpful for other people too ... This project is soooo good !!!

  I have read with great interest "CpmFetch will also return just data so that you can use it to query the database, then format the output to your specific needs."

  My goal is to be able to show album name, description, and number of pictures with formats in table cells (last three added albums of one Coppermine category, in thre cells).
  Of course, other relevant infos would be also interesting to show ...

  Any clues appreciated  ;)

L@urent

vuud

Quote from: florennes-as.be on June 02, 2007, 10:21:40 AM
Hello all !

  Is there a sample script of database query, output format of datas to be found easily, and to learn ?
  I do not have found as far as now ... And i think this can be helpful for other people too ... This project is soooo good !!!

  I have read with great interest "CpmFetch will also return just data so that you can use it to query the database, then format the output to your specific needs."

  My goal is to be able to show album name, description, and number of pictures with formats in table cells (last three added albums of one Coppermine category, in thre cells).
  Of course, other relevant infos would be also interesting to show ...

  Any clues appreciated  ;)

L@urent


See the cpg_setReturnType function.  That tells it to return an array of the data.

If you write and example, then post it and I will include it in the docs

Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco

florennes-as.be

I had a look at what you mentionned, and here is the first step of my searches ...

<?php
  include "./engine/cpmfetch/cpmfetch.php";
  $objCpm = new cpm("./engine/cpmfetch/cpmfetch_config.php");
  $objCpm->cpm_setReturnType ("resultset");
  $table = $objCpm->cpm_viewLastUpdatedAlbumsFrom("cat=2",3,1,$options);
  print_r($table) ;
  $objCpm->cpm_close();
?>

  This does the access to the last three albums, contained in category 2, and print the arrays returned by the function call.
  I have then a table with three sub tables, each containing all needed infos (explained in the online documentation) ! ... except the number of pictures of the album.
  Have i missed something, or do i have to do a php access to the Coppermine "album" table, with search of the album id (contained in the arrays) ?

  I am slowly improving as my skills in Php are, at best, rated "beginner" ;)

L@urent

florennes-as.be

After further investigations, here is the code i have tested ;

<?php
  include "./engine/cpmfetch/cpmfetch.php";
  $objCpm = new cpm("./engine/cpmfetch/cpmfetch_config.php");
  $objCpm->cpm_setReturnType ("resultset");
  $table = $objCpm->cpm_viewLastUpdatedAlbumsFrom("cat=2",3,1,$options);
?>
<body>
<pre>

<? $lien = "http://www.florennes-as.be/engine/thumbnails.php?album=" . $table[0][aAid] ; ?>
<? echo "<a href=\"  ". $lien . "\">" . "<img src=\" " . "engine/" . $table[0]["fullPathToThumb"] . "\" /></a>" ; ?>
<br />
<? echo "<a href=\"  ". $lien . "\">" . $table[0]["aTitle"] . "<a><br>" ; ?>

</pre>
<?php 
  $objCpm->cpm_close();
?>
</body>

The aim is to extract the last thumb of the most recent album, of caregory 2, do a link on this thumb, show below the name of the album, also with the same link.

Still no idea on how to extract the number of pictures contained in the album.

L@urent

vuud

Quote from: florennes-as.be on June 07, 2007, 10:29:56 PM
After further investigations, here is the code i have tested ;

<?php
  include "./engine/cpmfetch/cpmfetch.php";
  $objCpm = new cpm("./engine/cpmfetch/cpmfetch_config.php");
  $objCpm->cpm_setReturnType ("resultset");
  $table = $objCpm->cpm_viewLastUpdatedAlbumsFrom("cat=2",3,1,$options);
?>
<body>
<pre>

<? $lien = "http://www.florennes-as.be/engine/thumbnails.php?album=" . $table[0][aAid] ; ?>
<? echo "<a href=\"  ". $lien . "\">" . "<img src=\" " . "engine/" . $table[0]["fullPathToThumb"] . "\" /></a>" ; ?>
<br />
<? echo "<a href=\"  ". $lien . "\">" . $table[0]["aTitle"] . "<a><br>" ; ?>

</pre>
<?php 
  $objCpm->cpm_close();
?>
</body>

The aim is to extract the last thumb of the most recent album, of caregory 2, do a link on this thumb, show below the name of the album, also with the same link.

Still no idea on how to extract the number of pictures contained in the album.

L@urent

I do not think it will return that information for you...

Even more surprising I am not sure there is a clean way in cpmfetch to get the total number of photos in an album...

Oh duh.  There is a function named:
cpm_getMediaCountForAlbum

You name the album id and it tells you how many photos.  You will have to make a call for each album returned to get it.  So you will have to do 4 cpmfetch calls to do everything you want (the original, plus 1 getMediaCountForAlbum for each returned).

You may want to do a loop over the $table array below to make your output



Please post for help to the forum... PM me only if you are sending security related items (passwords, security problems, etc).

cpmFetch - Images, RSS feeds from CPG from outside CPG
New release notification signup also. 
See http://cpmfetch.fistfullofco