<?php
// $Id: table_broken.php,v 1.3 2005/10/28 11:56:02 ohwada Exp $

// 2004-11-28 K.OHWADA
// use module_base

// 2004/08/10 K.OHWADA
// enable to install this module two or more. 

//=========================================================
// class table_broken
// 2004/01/14 K.OHWADA
//=========================================================
class table_broken extends module_base
{
// tablefield
  var $bid;
  var $lid;
  var $sender;
  var $ip;

// local

//---------------------------------------------------------
// constructor
//---------------------------------------------------------
function table_broken()
{
	module_base::module_base( 'broken' );
}

function &getInstance()
{
	static $instance;
	if (!isset($instance)) 
	{
		$instance = new table_broken();
	}

	return $instance;
}

//---------------------------------------------------------
// insert
// for brokenlink.php
//---------------------------------------------------------
function insert($lid, $sender, $ip)
{
	$sql = "INSERT INTO $this->table (lid, sender, ip) VALUES ($lid, $sender, '$ip')";

    return  $this->query_false($sql);
}

//---------------------------------------------------------
// delete
//---------------------------------------------------------
// for admin/broken.php
function deleteByLid($lid)
{
	$sql = "DELETE FROM $this->table WHERE lid=$lid";
	return  $this->query_false($sql);
}

//---------------------------------------------------------
// select
//---------------------------------------------------------
// for admin/index.php:
function getNumAll()
{
	$sql = "SELECT count(*) FROM $this->table";
    return $this->get_num_by_sql($sql);
}

// for brokenlink.php
function getNumByLidSender($lid,$sender)
{
	$sql = "SELECT count(*) FROM $this->table WHERE lid=$lid AND sender=$sender";
    return $this->get_num_by_sql($sql);
}

// for brokenlink.php
function getNumByLidIp($lid,$ip)
{
	$sql = "SELECT count(*) FROM $this->table WHERE lid=$lid AND ip=$ip";
    return $this->get_num_by_sql($sql);
}

// for admin/broken.php
function getRowsGroupLid()
{
	$sql = "SELECT * FROM $this->table GROUP BY lid ORDER BY bid DESC";
	return $this->get_row_array_by_sql($sql);
}

//---------------------------------------------------------
}
?>
