Система индивидуальных тематических блогов

Постановка задачи разработки web-системы индивидуальных блогов. Создание основных программных модулей и элементов базы данных. Алгоритм работы с записями и комментариями, добавления математических формул. Расчет экономических показателей проекта.

Рубрика Программирование, компьютеры и кибернетика
Вид отчет по практике
Язык русский
Дата добавления 06.07.2012
Размер файла 3,1 M

Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже

Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.

$query=$this->db->query($new_sql,array($resource_fk,$user_account_fk,$value));

}

}

public function get_new()

{

$sql = ' select id_resource,resource_name,resource_type, pers.surname,pers.name,pers.patronymic,owner_fk

from access_management.resource res left join access_management.user_account acc on res.owner_fk=acc.id_account

left join general.person pers on acc.person_fk=pers.id

WHERE resource_type = '.TRESOURCE_BLOG.'

order by id_resource desc

limit 5';

$query= $this->db->query($sql);

return $query=$query->result_array();

}

public function get_pop_posts()

{$sql = "select id_resource, resource_name, resource_type,

pers.surname, pers.name, pers.patronymic, sum(value) OVER (PARTITION BY id_resource) as ratio,owner_fk

from access_management.resource res inner join access_management.user_account acc on res.owner_fk=acc.id_account

inner join general.person pers on acc.person_fk=pers.id

left join access_management.marks m on res.id_resource=m.resource_fk

WHERE resource_type = ".TRESOURCE_BLOG_POST."

order by ratio desc

limit 10";

$query= $this->db->query($sql);

return $query=$query->result_array();

}

public function edit_blog($id_resource,$resource_name,$resource_description ){

$sql ="update access_management.resource

set resource_description = ?,

resource_name = ?

where id_resource = ?";

$query = $this->db->query($sql,array($resource_description,$resource_name, $id_resource));

}

public function delBLog($id_resource){

$sql = "delete from access_management.resource

where id_resource = ?";

$this->db->query($sql,array($id_resource));

}

public function get_blog_child($id_resource){

$sql = " select id_resource from access_management.resource

where parent_fk = ?";

$res = $this->db->query($sql,array($id_resource));

return $res->result_array();

}

}

?>

Файл модели Post_model содержит следующий текст:

<?php

if (!defined('BASEPATH')) exit ('No direct script access allowed');

class Post_model extends CI_Model

{

public function __construct()

{

parent::__construct();

}

public function add_post($parent_fk,$resource_name,$resource_description,$owner_fk)

{

$resource_type=TRESOURCE_BLOG_POST;

$time_last_modify = date("Y-m-d G:i:s");

$sql = "insert into access_management.resource (parent_fk,resource_name,resource_type,resource_description,time_last_modify,owner_fk) ";

$sql.="values(?,?,?,?,?,?) returning id_resource";

$query = $this->db->query($sql,array($parent_fk,$resource_name,$resource_type,$resource_description,$time_last_modify,$owner_fk));

$query = $query->result_array();

return $query[0]['id_resource'];

}

public function get_post($id_resource)

{

$sql= "select id_resource,t1.parent_fk,resource_name,resource_description,

time_last_modify,owner_fk,surname,name,patronymic

from access_management.resource t1

inner join access_management.user_account t2

on t1.owner_fk=t2.id_account

inner join general.person t3 on t2.person_fk=t3.id

where t1.id_resource = ?";

$query = $this->db->query($sql,array($id_resource));

return $query;

}

public function get_count()

{

$sql = 'select count(*) as count

from access_management.resource

where resource_type = '. TRESOURCE_BLOG_POST;

$query = $this->db->query($sql);

return $query=$query->result_array();

}

public function get_post_count($id_resource)

{

$sql="select count(*) as count

from access_management.resource where parent_fk = ? ";

$query = $this->db->query($sql,array($id_resource));

return $query=$query->result_array();

}

public function get_post_mark($resource_fk)

{

$sql = "select SUM(value) as mark

from access_management.marks

where resource_fk = ?";

$query = $this-> db -> query($sql, array($resource_fk));

$query=$query->result_array();

if($query[0]['mark'])

{

return $query;

}

else

{

return $query[0]['mark']=0;

}

}

public function get_blog_title($id_resource)

{

$sql= "select parent_fk from access_management.resource where id_resource = ?";

$res=$this->db->query($sql, array($id_resource));

$sql2= "select resource_name from access_management.resource where id_resource = ?";

$res=$res->result_array();

$res1=$this->db->query($sql2, array($res[0]['parent_fk']));

return $res1=$res1->result_array();

}

public function update_post($id_resource, $resource_description, $resource_name)

{

$sql ="update access_management.resource

set resource_description = ?,

resource_name = ?

where id_resource = ?";

$query = $this->db->query($sql,array($resource_description,$resource_name, $id_resource));

}

public function del_post($id_resource)

{

$sql = "delete from access_management.resource

where id_resource = ?";

$this->db->query($sql,array($id_resource));

$sql ="delete from access_management.resource

where parent_fk = ?";

$this->db->query($sql,array($id_resource));

}

public function post_mark_plus($resource_fk,$user_account_fk)

{ $value= 1;

$sql=" select * from access_management.marks where resource_fk= ? and user_account_fk= ?";

$query=0;

$query = $this->db->query($sql,array($resource_fk, $user_account_fk));

if ($query->num_rows == 0)

{

$new_sql="insert into access_management.marks (resource_fk,user_account_fk,value) values (?,?,?)";

$query=$this->db->query($new_sql,array($resource_fk,$user_account_fk,$value));

return $res=1;

}

else

{

return $res=0;

}

}

public function post_mark_minus($resource_fk,$user_account_fk)

{

$value= -1;

$sql=" select * from access_management.marks where resource_fk= ? and user_account_fk= ?";

$query=0;

$query = $this->db->query($sql,array($resource_fk,$user_account_fk));

if ($query->num_rows == 0)

{

$new_sql="insert into access_management.marks (resource_fk,user_account_fk,value) values (?,?,?)";

$query=$this->db->query($new_sql,array($resource_fk,$user_account_fk,$value));

return $res=1;

}

else

{

return $res=0;

}

}

}

?>

Файл модели Comment_model содержит следующий текст:

<?php

if (!defined('BASEPATH')) exit ('No direct script access allowed');

class Comment_model extends CI_Model

{

public function __construct()

{

parent::__construct();

}

public function add_new_comment($id_resource,$parent_fk,$owner_fk,$resource_description)

{

$resource_type=TRESOURCE_BLOG_COMMENT;

$name="select resource_name from access_management.resource where id_resource = ?";

$name = $this->db->query($name, array($id_resource));

$name=$name->result_array();

$name= $name[0]['resource_name'];

$time_last_modify = date("Y-m-d G:i:s");

$sql = "insert into access_management.resource (parent_fk,resource_name,resource_type,resource_description,time_last_modify,owner_fk) ";

$sql.= "values(?,?,?,?,?,?) returning id_resource;";

$query = $this->db->query($sql,array($parent_fk,$name,$resource_type,$resource_description,$time_last_modify,$owner_fk));

$query = $query->result_array();

return $query[0]['id_resource'];

}

public function get_comments($parent_fk)

{

$sql= "select id_resource,t1.parent_fk,resource_name,resource_description,

time_last_modify, owner_fk,surname,name,patronymic,sum(value)

from access_management.resource t1

inner join access_management.user_account t2 on t1.owner_fk=t2.id_account

inner join general.person t3 on t2.person_fk=t3.id

left join access_management.marks t34 on t1.id_resource=t34.resource_fk

where t1.parent_fk = ?

group by id_resource,t1.parent_fk,resource_name,

resource_description, time_last_modify,

owner_fk,surname,name,patronymic

order by time_last_modify";

$query = $this->db->query($sql,array($parent_fk));

return $query;

}

public function get_comment_by_id($res)

{

$sql= "select id_resource,t1.parent_fk,resource_name,resource_description,

time_last_modify, owner_fk,surname,name,patronymic,sum(value)

from access_management.resource t1

inner join access_management.user_account t2 on t1.owner_fk=t2.id_account

inner join general.person t3 on t2.person_fk=t3.id

left join access_management.marks t34 on t1.id_resource=t34.resource_fk

where t1.id_resource = ?

group by id_resource,t1.parent_fk,resource_name,resource_description,

time_last_modify, owner_fk,surname,name,patronymic";

$query = $this-> db->query($sql, array($res));

$query = $query -> first_row('array');

return $query;

}

public function update_comment($id_resource, $resource_description)

{

$sql ="update access_management.resource

set resource_description = ?

where id_resource = ?";

$query = $this->db->query($sql,array($resource_description, $id_resource));

}

public function del_comment($id_resource)

{

$sql ="delete from access_management.resource

where id_resource = ?

";

$this->db->query($sql,array($id_resource));

}

public function get_comments_count($id_resource)

{

$sql="select count(*)as count

from access_management.resource

where parent_fk in

(select id_resource from access_management.resource where parent_fk = ?) ";

$query = $this->db->query($sql,array($id_resource));

return $query=$query->result_array();

}

public function comment_mark_plus($resource_fk,$user_account_fk)

{ $value= 1;

$sql=" select * from access_management.marks where resource_fk= ? and user_account_fk= ?";

$query=0;

$query = $this->db->query($sql,array($resource_fk, $user_account_fk));

if ($query->num_rows == 0)

{

$new_sql="insert into access_management.marks

(resource_fk,user_account_fk,value)

values (?,?,?)";

$query=$this->db->query($new_sql,array($resource_fk,$user_account_fk,$value));

return $res=1;

}

else

{

return $res=0;

}

}

public function comment_mark_minus($resource_fk,$user_account_fk)

{

$value= -1;

$sql=" select * from access_management.marks where resource_fk= ? and user_account_fk= ?";

$query=0;

$query = $this->db->query($sql,array($resource_fk,$user_account_fk));

if ($query->num_rows == 0)

{

$new_sql="insert into access_management.marks

(resource_fk,user_account_fk,value)

values (?,?,?)";

$query=$this->db->query($new_sql,array($resource_fk,$user_account_fk,$value));

return $res=1;

}

else

{

return $res=0;

}

}

public function get_comment_mark($resource_fk)

{

$sql = "select SUM(value) as Cmark

from access_management.marks

where resource_fk = ?";

$query = $this-> db -> query($sql, array($resource_fk));

$query=$query->result_array();

if($query[0]['cmark'])

{

return $query;

}

else

{

return $query[0]['cmark']=0;

}

}

}

?>

Размещено на Allbest.ru


Подобные документы

Работы в архивах красиво оформлены согласно требованиям ВУЗов и содержат рисунки, диаграммы, формулы и т.д.
PPT, PPTX и PDF-файлы представлены только в архивах.
Рекомендуем скачать работу.