PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Links

When querying links, results are returned in descending order by date added. Links can be searched by title, nickname, tags, note, or even the content of the web page associated with the link. Simpy offers searching by any or all of these fields with phrases, boolean operators, and wildcards. See the search syntax and search fields sections of the Simpy FAQ for more information.

Example 817. Querying Links

<?php
$simpy 
= new Zend_Service_Simpy('yourusername''yourpassword');

/* Search for the 10 links added most recently */
$linkQuery = new Zend_Service_Simpy_LinkQuery();
$linkQuery->setLimit(10);

/* Get and display the links */
$linkSet $simpy->getLinks($linkQuery);
foreach (
$linkSet as $link) {
    echo 
'<a href="';
    echo 
$link->getUrl();
    echo 
'">';
    echo 
$link->getTitle();
    echo 
'</a><br />';
}

/* Search for the 5 links added most recently with 'PHP' in
the title */
$linkQuery->setQueryString('title:PHP');
$linkQuery->setLimit(5);

/* Search for all links with 'French' in the title and
'language' in the tags */
$linkQuery->setQueryString('+title:French +tags:language');

/* Search for all links with 'French' in the title and without
'travel' in the tags */
$linkQuery->setQueryString('+title:French -tags:travel');

/* Search for all links added on 12/9/06 */
$linkQuery->setDate('2006-12-09');

/* Search for all links added after 12/9/06 (excluding that
date) */
$linkQuery->setAfterDate('2006-12-09');

/* Search for all links added before 12/9/06 (excluding that
date) */
$linkQuery->setBeforeDate('2006-12-09');

/* Search for all links added between 12/1/06 and 12/9/06
(excluding those two dates) */
$linkQuery->setBeforeDate('2006-12-01');
$linkQuery->setAfterDate('2006-12-09');

Links are represented uniquely by their URLs. In other words, if an attempt is made to save a link that has the same URL as an existing link, data for the existing link will be overwritten with the data specified in the save attempt.

Example 818. Modifying Links

<?php
$simpy 
= new Zend_Service_Simpy('yourusername''yourpassword');

/* Save a link */
$simpy->saveLink(
    
'Zend Framework' // Title
    
'http://framework.zend.com'// URL
    
Zend_Service_Simpy_Link::ACCESSTYPE_PUBLIC// Access Type
    
'zend, framework, php' // Tags
    
'Zend Framework home page' // Alternative title
    
'This site rocks!' // Note
);

/* Overwrite the existing link with new data */
$simpy->saveLink(
    
'Zend Framework'
    'http://framework.zend.com'
,
    
Zend_Service_Simpy_Link::ACCESSTYPE_PRIVATE// Access Type has changed
    
'php, zend, framework' // Tags have changed order
    
'Zend Framework' // Alternative title has changed
    
'This site REALLY rocks!' // Note has changed
);

/* Delete the link */
$simpy->deleteLink('http://framework.zend.com');

/* A really easy way to do spring cleaning on your links ;) */
$linkSet $this->_simpy->getLinks();
foreach (
$linkSet as $link) {
    
$this->_simpy->deleteLink($link->getUrl());
}

Zend Framework