]>
Tony Duckles's Git Repositories (git.nynim.org) - delicious-utils.git/blob - delicious-dump/php-delicious/examples/mysql-backup/restore-from-mysql.php
2 // Import into del.icio.us from MySql
3 // Written by Ed Eliot (www.ejeliot.com) - November 2006
5 require('../../php-delicious.inc.php'); // see www.ejeliot.com/pages/php-delicious for more details on library
7 define('DELICIOUS_USER', 'YOUR_USER');
8 define('DELICIOUS_PASS', 'YOUR_PASS');
10 define('MYSQL_SERVER', 'YOUR_HOST');
11 define('MYSQL_DB', 'delicious');
12 define('MYSQL_USER', 'YOUR_USER');
13 define('MYSQL_PASS', 'YOUR_PASS');
15 define('POSTS_TABLE', 'posts');
16 define('TAGS_TABLE', 'tags');
18 $oDelicious = new PhpDelicious(DELICIOUS_USER
, DELICIOUS_PASS
);
20 if ($oDb = mysql_connect(MYSQL_SERVER
, MYSQL_USER
, MYSQL_PASS
)) {
21 if (mysql_select_db(MYSQL_DB
, $oDb)) {
22 if ($oPosts = mysql_query("select url, description, notes, hash, updated from posts order by updated asc", $oDb)) {
23 while ($aPost = mysql_fetch_assoc($oPosts)) {
25 if ($oTags = mysql_query(sprintf("select tag from tags where hash = '%s' order by tag asc", $aPost['hash']))) {
26 while ($aTag = mysql_fetch_assoc($oTags)) {
27 $aTags[] = $aTag['tag'];
30 $oDelicious->AddPost($aPost['url'], $aPost['description'], $aPost['notes'], $aTags, $aPost['updated'], true);
34 echo mysql_error($oDb);
38 echo "Could not connect to MySql server.";