<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Cross_ref_write {
// var $tag_scope = FALSE; // tag or parent or category or shortcut
// we have two tables to deal with, so this will probably be a problem...
var $id = '';
var $biblio_id = '';
var $profile_id = '';
var $tag_id = '';
var $page_id = '';
var $course_id = '';
var $coll_id = '';
function delete($primary = NULL, $primary_id = NULL, $related_scope = NULL)
{
$this->db->where("{$primary_scope}_id", $primary_id);
$this->db->where("{$related_scope}_id NOT ", 0);
$this->db->delete('cross_ref');
}
function delete_all()
{
}
function add_one($primary_scope = NULL, $primary_id = NULL, $related_scope = NULL, $related_id = NULL)
{
}
function save($primary_scope = NULL, $primary_id = NULL, $related_scope = NULL, $related_ids = NULL)
{
{
return FALSE;
}
else
{
// proceed
$CI =& get_instance();
try
{
// DELETE from CROSS_REF where {primary_scope}_id =
// housekeeping is easier if we wipe the slate clean, rather than update existing.
// then we add/re-add them in fresh below
$CI->db->where("{$primary_scope}_id", $primary_id);
$CI->db->where("{$related_scope}_id NOT ", 0);
$CI->db->delete('cross_ref');
// ADD to CROSS_REF
// loop through related id's INSERT one at a time
foreach($related_ids as $related_id)
{
if($related_id != '')
{
"{$primary_scope}_id" => $primary_id,
"{$related_scope}_id" => $related_id
);
}
$CI->db->insert('cross_ref', $cross);
}
return TRUE;
}
catch ()
{
return FALSE;
}
}
}
} // EOF