Ver Mensaje Individual
  #2 (permalink)  
Antiguo 08/02/2013, 09:16
escar_matrix
 
Fecha de Ingreso: febrero-2013
Mensajes: 3
Antigüedad: 11 años, 2 meses
Puntos: 0
Respuesta: Problema con los includes en mi web

PostDAL.php

<?php

/**
* Configuration Class of own web
* @author Javier Escartin
*/
//include_once 'includes/config/connect.php';
include("../includes/config/connect.php");
//include 'includes/config/config.php';


class PostDAL{

public function get_posts_from_blog()
{
global $db;
//$db = new DB('DB_USER', 'DB_PASSWORD', 'DB_NAME', 'DB_HOST');
//$db->quick_connect(DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
$resultPosts = $db->get_results("SELECT * FROM posts");
$index = 0;
$listAllPosts;
foreach($resultPosts as $resultPost)
{
$post = new Post();
$post->setIdPost($resultPost->Id);
$post->setIdUser($resultPost->Id_user);
$post->setTitle($resultPost->Title);
$post->setAuthor($resultPost->Author);
$post->setContent($resultPost->Content);
$post->setDateCreated($resultPost->Date_created);
$post->setDateModificated($resultPost->Date_modificated);
$post->setDatePublished($resultPost->Date_published);
$post->setExcerpt($resultPost->Excerpt);
$post->setThumbnail($resultPost->Thumbnail);
$post->setThumbnailTitle($resultPost->Thumbnail_Title);
$post->setCommentCount($resultPost->Comment_count);
$post->setPublished($resultPost->Published);

$listAllPosts[$index] = $post;
$index++;
}
return $listAllPosts;
}

public function get_posts_from_admin()
{
global $db;

$resultPosts = $db->get_results("SELECT * FROM posts");
$index = 0;
$listAllPosts;
foreach($resultPosts as $resultPost)
{
$post = new Post();
$post->setIdPost($resultPost->Id);
$post->setTitle($resultPost->Title);
$post->setAuthor($resultPost->Author);
$post->setDateCreated($resultPost->Date_created);
$post->setDateModificated($resultPost->Date_modificated);
$post->setDatePublished($resultPost->Date_published);
$post->setExcerpt($resultPost->Excerpt);
$post->setThumbnail($resultPost->Thumbnail);
$post->setCommentCount($resultPost->Comment_count);
$post->setPublished($resultPost->Published);

$listAllPosts[$index] = $post;
$index++;
}
return $listAllPosts;
}

public function create_new_post(&$postObj)
{
global $db;
$idUser = $postObj->getIdUser();
$title = $postObj->getTitle();
$author = $postObj->getAuthor();
$content = $postObj->getContent();
$dateCreated = $postObj->getDateCreated();
$dateModificated = $postObj->getDateModificated();
$datePublished = $postObj->getDatePublished();
$dateExcerpt = $postObj->getDateExcerpt();
$thumbnail = $postObj->getThumbnail();
$thumbnailTitle = $postObj->getThumbnailTitle();
$published = $postObj->getPublished();

$query = "INSERT INTO posts VALUES (null, )";
$db->query($query);
}
}
?>
Post.php
<?php

/**
* Class of definition POST type
* @author Javier Escartin
*/

class Post{
private $idPost;
private $idUser;
private $author;
private $title;
private $content;
private $date_created;
private $date_modificated;
private $date_published;
private $excerpt;
private $comment_count;
private $thumbnail;
private $thumbnailTitle;
private $published;
//GETTERS
public function getIdPost(){return $this->idPost;}
public function getIdUser(){return $this->idUser;}
public function getAuthor(){return $this->author;}
public function getTitle(){return $this->title;}
public function getContent(){return $this->content;}
public function getDateModificated(){return $this->date_modificated;}
public function getDateCreated(){return $this->date_created;}
public function getDatePublished(){return $this->date_published;}
public function getExcerpt(){return $this->excerpt;}
public function getCommentCount(){return $this->comment_count;}
public function getThumbnail(){return $this->thumbnail;}
public function getThumbnailTitle(){return $this->thumbnailTitle;}
public function getPublised(){return $this->published;}
//SETTERS
public function setIdPost($idPost){$this->idPost = $idPost;}
public function setIdUser($idUser){$this->idUser = $idUser;}
public function setAuthor($author){$this->author = $author;}
public function setTitle($title){$this->title = $title;}
public function setContent($content){$this->content = $content;}
public function setDateModificated($date_modificated){$this->date_modificated = $date_modificated;}
public function setDateCreated($date_created){$this->date_created = $date_created;}
public function setDatePublished($date_published){$this->date_published = $date_published;}
public function setExcerpt($excerpt){$this->excerpt = $excerpt;}
public function setCommentCount($comment_count){$this->comment_count = $comment_count;}
public function setThumbnail($thumbnail){$this->thumbnail = $thumbnail;}
public function setThumbnailTitle($thumbnailTitle){$this->thumbnailTitle = $thumbnailTitle;}
public function setPublished($published){$this->published = $published;}
}
?>
blog.php
<?php
require 'header.php';
require_once 'includes/classes/Post.php';
require_once 'includes/classes/PostDAL.php';


?>
<div id="bodyPage">
<div id="page-bgtop">
<div id="page-bgbtm">
<div id="content">
<?php
$postDAL = new PostDAL();
$listPosts = $postDAL->get_posts_from_blog();

for($c=0; $c<sizeof($listPosts); $c++)
{
$post = new Post();
$post = $listPosts[$c];
?>
<div class="post">
<h2 class="title"><a href="#"><?php echo $post->getTitle(); ?> </a></h2>
<p class="meta">Publicado en <?php echo $post->getDatePublished(); ?>
<a href="#" class="comments">Commentarios <?php echo $post->getCommentCount(); ?></a> &nbsp;&bull;&nbsp; <a href="#" class="permalink">Seguir leyendo...</a></p>
<div class="entry">
<p>
<img src="uploads/<?php $post->getThumbnail(); ?>" width="140" height="140" alt="<?php $post->getThumbnailTitle(); ?>" class="alignleft border" />
<?php echo $post->getExcerpt(); ?>
</p>
</div>
</div>
<?php } ?>
<div style="clear: both;">&nbsp;</div>
</div>
<!-- end #content -->
<?php require 'sidebar.php'; ?>
<?php require 'footer.php'; ?>
connect.php
<?php
include_once "../includes/libExt/ezSQL/shared/ez_sql_core.php";
include_once "../includes/libExt/ezSQL/mysql/ez_sql_mysql.php";
require_once '../includes/config/config.php';


// Initialise database object and establish a connection
// at the same time - db_user / db_password / db_name / db_host
$db = new ezSQL_mysql('root', '', 'dbje', 'localhost');
?>