PHP Classes
Icontem

File: mysql.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Cesar D. Rodas  >  guaranix Rank  >  mysql.php  
File: mysql.php
Role: Auxiliary script
Content type: text/plain
Description: This is the MySQL functions
Class: guaranix Rank
Implementation of the Google page rank algorithm
 

Contents

Class file image Download
<?
/*
*    Prepare
*/
$sql[] = "DROP TABLE IF EXISTS tmp_pr";
$sql[] = "
    CREATE TABLE tmp_pr (
      id bigint(20) NOT NULL default '0',
      formula longtext NOT NULL,
      nroout int(11) NOT NULL default '0',
      pr float NOT NULL default '0',
      PRIMARY KEY  (id),
      KEY nroout (nroout)
    )"
;

/*
*    
*/
$sql[] = "CREATE TABLE tmp_nodanglins AS SELECT count( * ) as total, master FROM pagerank GROUP BY MASTER";
$sql[] = "ALTER TABLE `tmp_nodanglins` ADD PRIMARY KEY ( `master` ) ";

/*
*    
*/
$sql[] = "CREATE TABLE tmp_unilist as (select distinct master as id from pagerank) union (select distinct slave as id from pagerank)";
$sql[] = "ALTER TABLE `tmp_unilist` ADD PRIMARY KEY ( `id` ) ;";

/*
*    
*/
$sql[] = "Insert into tmp_pr(id,nroout) select tmp_unilist.id, tmp_nodanglins.total  from tmp_unilist left join tmp_nodanglins  on (tmp_nodanglins.master = tmp_unilist.id)";


/*
*    This SQL command are executed when the PR calculation finish.
*/
$sql_finish[] = "DROP TABLE IF EXISTS PR_FINISHED";
$sql_finish[] = "CREATE TABLE `PR_FINISHED` (
  `posicion` int(11) NOT NULL auto_increment,
  `id` int(11) NOT NULL default '0',
  `pagerank` float NOT NULL default '0',
  PRIMARY KEY  (`posicion`),
  UNIQUE KEY `id` (`id`),
  KEY `pagerank` (`pagerank`)
)"
;

$sql_finish[] = "INSERT INTO PR_FINISHED(id,pagerank) SELECT tmp_pr.id,tmp_pr.pr FROM tmp_pr ORDER BY tmp_pr.pr DESC";

$sql_finish[] = "DROP TABLE tmp_unilist;";
$sql_finish[] = "DROP TABLE tmp_pr;";
$sql_finish[] = "DROP TABLE tmp_nodanglins;";
?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products