Esempio n. 1
0
echo var_dump($data_left);
if (sizeof($data_left) == 5)
{
    echo "passed mass delete test with content<br />";
}
else
{
    echo "failed mass delete test with content<br />";
}



$inserts = array();
$inserts[] = DBDataType::CreateData("test", 123, DBDataType::DATATYPE_TEXT, "content 1", "test:test1");
$inserts[] = DBDataType::CreateData("test", 124, DBDataType::DATATYPE_TEXT, "content 2", "test:test2");
$inserts[] = DBDataType::CreateData("test", 125, DBDataType::DATATYPE_TEXT, "content 3", "test:test3");
echo var_dump($inserts);


$data = DBDataType::GetPrimaryData("test", 123);
if ($data[DBDataType::METADATA] == "test:test1")
{
    echo "passed insert and get test with meta<br />";
}
else
{
    echo "failed insert and get test with meta<br />";
}
DBDataType::UpdateContentFromID("content 1 extended",
        $data[DBDataType::DATATYPE_ID]);
$data = DBDataType::GetDataContentFromOrigin("test", 123);
Esempio n. 2
0
 /**
  *
  * @param <type> $post_origin_type
  * @param <type> $post_origin_id
  * @param <type> $content
  * @param <type> $order
  * @param <type> $parent the parent of the post... if this is set to zero,
  * then it assumes root
  */
 public function post_create(
         $post_origin_type,
         $post_origin_id,
         $content, $parent = 0, $order = false, $metadata = '')
 {
     self::validate_content($content, $this->post_datatype);
     if (!is_numeric($parent))
     {
         throw new DBForumException(
                 '$parent must be numeric');
     }
     if ($post_origin_type == null || $post_origin_type == "")
     {
         throw new DBForumException(
                 '$post_origin_type cannot be null or empty');
     }
     if (!is_null($post_origin_id) && !is_numeric($post_origin_id))
     {
         throw new DBForumException(
                 '$post_origin_id cannot be null or non numeric');
     }
     if (!is_bool($order) && !is_numeric($order))
     {
         throw new DBForumException(
                 '$order must be boolean or numeric');
     }
     if (!is_string($metadata))
     {
         throw new DBDataTypeException(
                 '$metadata must be a string');
     }
     try
     {
         if ($parent != 0)
         {
             if (null == $this->db->quick_query(
                     "SELECT ".self::POST_ID." FROM ".self::FCORE_FORUM_POST." WHERE
                         ".self::FORUM_ID."=$this->forum_id AND
                         ".self::POST_ID."=$parent", true))
             {
                 throw new Exception(
                         'parent id for the post does not exist in this thread');
             }
         }
         if (is_bool($order))
         {
             $order = $this->db->quick_query(
                     "SELECT max(".self::POSTORDER.") FROM ".self::FCORE_FORUM_POST." WHERE
                         ".self::POSTPARENT."=$parent AND
                         ".self::FORUM_ID."=$this->forum_id", true);
             if ($order == null)
             {
                 $order = 0;
             }
             else
             {
                 $order = $order[0]["max(".self::POSTORDER.")"];
                 $order++;
             }
         }
         $this->db->quick_query(
                 "INSERT INTO ".self::FCORE_FORUM_POST." SET
                     ".self::FORUM_ID."=$this->forum_id,
                     ".self::POSTPARENT."=$parent,
                     ".self::ORIGIN_ID."=$post_origin_id,
                     ".self::ORIGIN_TYPE."='$post_origin_type',
                     ".self::POSTORDER."=$order,
                     ".self::METADATA."='$metadata'");
         $post_id = $this->db->get_last_insert();
         DBDataType::CreateData(
                 self::build_datatype_origin($this->origin_type),
                 $post_id,
                 $this->post_datatype,
                 $content);
         $this->db->commit();
         return $post_id;
     }
     catch(Exception $e)
     {
         $this->db->rollback();
         throw new DBForumException($e->getMessage());
     }
 }