id;
$db_result = mysql_query($db_query);
if (!$db_result) die (MSG_ERROR_SQL . mysql_error() . " " .$db_query);
else {
$db_row = mysql_fetch_row($db_result);
$this->id = $db_row[0];
$this->number = $db_row[1];
}
} /* }}} */
public function data_insert() { /* {{{ ************************************/
db_connect();
$db_query = "INSERT INTO c_phone (" .
($this->id > 0? "pk_c_phone, " : "").
"number ".
") VALUES (".
($this->id > 0? "'" . $this->id . "', ": "").
"'". $this->number . "')";
$db_result = mysql_query($db_query);
if (!$db_result) die ('Chyba SQL: ' . mysql_error() . " " .$db_query);
else $this->id = mysql_insert_id();
return true;
} /* }}} */
public function data_update() { /* {{{ ************************************/
db_connect();
$db_query = "UPDATE c_phone SET " .
"number='". $this->number . "'".
"WHERE pk_c_phone='". $this->id ."'";
if ($this->id > 0) $db_result = mysql_query($db_query);
if (!$db_result) die ('Chyba SQL: ' . mysql_error() . " " .$db_query);
return true;
} /* }}} */
public function data_delete() { /* {{{ ************************************/
db_connect();
$db_query = "DELETE FROM c_phone WHERE pk_c_phone=". $this->id ;
$db_result = false;
if ($this->id > 0)
if (mysql_query($db_query)) {
$db_query = "DELETE FROM c_join_person_phone " .
"WHERE fk_c_phone=". $this->id ;
$db_result += mysql_query($db_query);
$db_query = "DELETE FROM c_join_company_phone " .
"WHERE fk_c_phone=". $this->id ;
$db_result += mysql_query($db_query);
}
if (!$db_result) die ('Chyba SQL: ' . mysql_error() . " " .$db_query);
return true;
} /* }}} */
public function data_insert_relation_person($p_id_person) { /* {{{ ********/
db_connect();
$db_query = "INSERT INTO c_join_person_phone (".
"fk_c_phone, ".
"fk_c_person ".
") VALUES (" .
$this->id .",".
$p_id_person .")";
$db_result = mysql_query($db_query);
if (!$db_result) die (MSG_ERROR_SQL . mysql_error() . " " .$db_query);
return true;
} /* }}} */
public function data_insert_relation_company($p_id_company) { /* {{{ ******/
db_connect();
$db_query = "INSERT INTO c_join_company_phone (".
"fk_c_phone, ".
"fk_c_company ".
") VALUES (" .
$this->id .",".
$p_id_company .")";
$db_result = mysql_query($db_query);
if (!$db_result) die (MSG_ERROR_SQL . mysql_error() . " " .$db_query);
return true;
} /* }}} */
public function print_list_person() { /* {{{ ******************************/
db_connect();
$db_query = "SELECT ".
"pk_c_join_person_phone, ".
"pk_c_person, " .
"priority, ".
"note, " .
"name, " .
"surname " .
"FROM c_join_person_phone ".
"INNER JOIN c_person ON fk_c_person=pk_c_person " .
"WHERE fk_c_phone=" . $this->id . " " .
"ORDER BY surname";
$db_result = mysql_query($db_query);
if (!$db_result) die (MSG_ERROR_SQL . mysql_error() . " " . $db_query);
else if (mysql_num_rows($db_result)>0) {
?>
id . " " .
"GROUP BY pk_c_company " .
"ORDER BY c_company.name";
$db_result = mysql_query($db_query);
if (!$db_result) die (MSG_ERROR_SQL . mysql_error() . " " . $db_query);
else if (mysql_num_rows($db_result)>0) {
?>
0) {
?>