예제 #1
0
 /**
  * Metodo que inserta los datos.
  * @return bool Si es TRUE, todo se realizo correctamente.
  */
 public function insert()
 {
     $db = DBController::getConnection();
     $table = PostCategory::getTableName();
     $count = \count($this->categoriesID);
     $error = \FALSE;
     for ($i = 0; $i < $count && !$error; ++$i) {
         $categoryID = $this->categoriesID[$i];
         $this->prepareStatement = [];
         $this->prepare($categoryID);
         $error = !$db->insert($table, self::$COLUMNS, self::$VALUES, $this->prepareStatement);
     }
     return !$error;
 }
예제 #2
0
 /**
  * Metodo que borra los datos.
  * @return bool Si es TRUE, todo se realizo correctamente.
  */
 public function delete()
 {
     $db = DBController::getConnection();
     $table = PostCategory::getTableName();
     $parameterCategoryID = PostCategory::RELATIONSHIPS_CATEGORY_ID;
     $parameterPostID = PostCategory::RELATIONSHIPS_POST_ID;
     $where = "{$parameterCategoryID} = :{$parameterCategoryID} AND {$parameterPostID} = :{$parameterPostID}";
     $count = \count($this->categoriesID);
     $error = \FALSE;
     for ($i = 0; $i < $count && !$error; ++$i) {
         $categoryID = $this->categoriesID[$i];
         $this->prepareStatement = [];
         $this->prepare($categoryID);
         $error = !$db->delete($table, $where, $this->prepareStatement);
     }
     return !$error;
 }
예제 #3
0
 /**
  * Metodo que realiza una consulta a la base de datos.
  * @param string $where [Opcional] Condiciones.
  * @param array $prepare [Opcional] Lista de indices a reemplazar en la consulta.
  * @param string $columns [Opcional] Por defecto "*". Columnas.
  * @param int $limit [Opcional] Numero de datos a retornar.
  * @return PostsCategories
  */
 private static function select($where = '', $prepare = [], $columns = '*', $limit = '')
 {
     $db = DBController::getConnection();
     $table = PostCategory::getTableName();
     $fetch = 'fetchAll';
     $select = $db->select($table, $fetch, $where, $prepare, $columns, '', $limit);
     $postsCategories = new PostsCategories();
     $postsCategories->addPostsCategories($select);
     return $postsCategories;
 }