Share » Forums » Setup & design » fetch Information Collection information

fetch Information Collection information

fetch Information Collection information

Thursday 26 June 2008 6:37:01 pm - 2 replies

Modified on Thursday 26 June 2008 8:14:55 pm by Michael Scofield

Author Message

Piotrek Karaƛ

Thursday 26 June 2008 10:01:27 pm

For (almost) any db table (set) there is a corresponding dedicated PHP class extending eZPersistentObject, providing API for all the key operations on this particular dataset. If you want to be consistent, use that. For collected info, you have eZInformationCollection and eZInformationCollectionAttribute classes. You can extend them to write your own fetches or direct SQL queries - and it would be your decision which ones you use and for what purpose.

Much as I appreciate the idea behind quick and general purpose information collection, in most cases I find dedicated tables and classes encapsulated within custom extension a better choice.

Cheers,
Piotrek

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Michael Scofield

Thursday 26 June 2008 10:20:05 pm

I just did it.

I will write the code I used in hope that it will help someone:

// gets DB instance			
$db = eZDB::instance();
				
// SQL
$sql = "
   SELECT 
      count( ezinfocollection_attribute.id ) as count 
   FROM 
      ezinfocollection_attribute
   WHERE 
      ezinfocollection_attribute.contentobject_attribute_id = '" . $contentObjectAttribute->attribute('id') . "'
      AND ezinfocollection_attribute.contentclass_attribute_id = '" . $contentObjectAttribute->attribute('contentclassattribute_id') . "'
      AND ezinfocollection_attribute.data_text LIKE '" . addslashes($email) . "'
				";
				
// executes query
$resArray = $db->arrayQuery( $sql );
				
// verifies if the e-mail was found
if (intval($resArray[0]['count']) > 0) {
   // found

}
// not found

Michael

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu