Beispiel #1
0
 /**
  * Metodo que inserta los datos.
  * @return bool Si es TRUE, todo se realizo correctamente.
  */
 public function insert()
 {
     $db = DBController::getConnection();
     $table = PostTerm::getTableName();
     $count = \count($this->termsID);
     $error = \FALSE;
     for ($i = 0; $i < $count && !$error; ++$i) {
         $termID = $this->termsID[$i];
         $this->prepareStatement = [];
         $this->prepare($termID);
         $error = !$db->insert($table, self::$COLUMNS, self::$VALUES, $this->prepareStatement);
     }
     return !$error;
 }
Beispiel #2
0
 /**
  * Metodo que borra los datos.
  * @return bool Si es TRUE, todo se realizo correctamente.
  */
 public function delete()
 {
     $db = DBController::getConnection();
     $table = PostTerm::getTableName();
     $parameterTermID = PostTerm::RELATIONSHIPS_TERM_ID;
     $parameterPostID = PostTerm::RELATIONSHIPS_POST_ID;
     $where = "{$parameterTermID} = :{$parameterTermID} AND {$parameterPostID} = :{$parameterPostID}";
     $count = \count($this->termsID);
     $error = \FALSE;
     for ($i = 0; $i < $count && !$error; ++$i) {
         $termID = $this->termsID[$i];
         $this->prepareStatement = [];
         $this->prepare($termID);
         $error = !$db->delete($table, $where, $this->prepareStatement);
     }
     return !$error;
 }
Beispiel #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 PostsTerms
  */
 private static function select($where = '', $prepare = [], $columns = '*', $limit = '')
 {
     $db = DBController::getConnection();
     $table = PostTerm::getTableName();
     $fetch = 'fetchAll';
     $select = $db->select($table, $fetch, $where, $prepare, $columns, '', $limit);
     $postsTerms = new PostsTerms();
     $postsTerms->addPostsTerms($select);
     return $postsTerms;
 }