<?php
require_once('inc/db_connect.php');
require_once('inc/base.php');
require_once('inc/debug.php');
require_once('class/keksdata.php');
class ContactMethod extends KeksData
{
function __construct($init = NULL)
{
$this->default_table = 'kundendaten.kundenkontakt';
$this->setup();
if ($init != NULL)
switch (gettype($init))
{
case 'string':
$this->loadByAddress($init);
break;
case 'integer':
$this->loadByID($init);
break;
}
}
function loadByAddress($name)
{
$name = mysql_real_escape_string($name);
DEBUG("Requested to load ContactMethod-object for address »{$name}«");
$res = $this->getData("*", "wert='{$name}' LIMIT 1");
if (count($res) < 1)
{
DEBUG('nothing found');
return false;
}
$this->parse($res[0]);
return true;
}
function loadByCustomer($cid, $comment = '')
{
$cid = (int) $cid;
$comment = mysql_real_escape_string($comment);
DEBUG("Requested to load ContactMethod-object for customer »{$cid}« (comment = {$comment})");
$res = $this->getData("*", "kundennr='{$cid}' AND (comment='{$comment}' OR (comment IS NULL AND '{$comment}'='')) LIMIT 1");
if (count($res) < 1)
{