public function fetchAll()
 {
     $select = new Select('socialmedia_credentials');
     $select->addAllFields();
     $result = $this->_dao->select($select);
     $this->row = $result[0];
 }
Пример #2
0
 protected function getMaxSequence($arrCriteria = array())
 {
     $entity_tbl = $this->_entity->getTbl();
     $select = new Select($entity_tbl);
     if ($this->_entity->hasTrash()) {
         $arrCriteria['is_del = 0'] = null;
     }
     $select->where($arrCriteria);
     return $this->_dao->select_count($select);
 }
Пример #3
0
 public function validate($prop, $label)
 {
     $value = $this->getValue($prop);
     $arrCriteria = array("{$prop} = ?" => $value);
     $select = new Select($this->_tablename);
     $select->where($arrCriteria);
     $count = $this->_dao->select_count($select);
     if (!$count) {
         $this->addException("{$label} não encontrado");
     }
 }
Пример #4
0
 public function batch_delete($id_photo, $gallery_sequence)
 {
     $arr_criteria = array("{$this->_id_photo} = ?" => $id_photo, "{$this->_id_photo_item} NOT IN (?)" => $gallery_sequence);
     $select = new Select($this->_photo_item);
     $select->addField($this->_id_photo_item);
     $select->where($arr_criteria);
     $result = $this->_dao->select($select);
     foreach ($result as $row) {
         Folder::delete("public/system/uploads/{$this->_photo}/{$id_photo}/{$this->_photo_item}/{$row[$this->_id_photo_item]}");
     }
     $this->_dao->delete($this->_photo_item, $arr_criteria);
 }
Пример #5
0
 public function getById($id = null)
 {
     if ($id) {
         $this->setId($id);
     }
     $arrCriteria = array('id_log = ?' => $this->getId());
     $select = new Select('log');
     $select->addAllFields();
     $select->where($arrCriteria);
     $result = $this->_dao->select($select);
     if (!count($result)) {
         throw new Exception('Registro não encontrado.');
     }
     $row = $this->formatTable($result[0]);
     return $row;
 }
Пример #6
0
 public function validate($prop, $label)
 {
     $value = $this->getValue($prop);
     if (is_null($this->_fieldname)) {
         $this->_fieldname = $prop;
     }
     $arrCriteria = array("{$this->_fieldname} = ?" => $value);
     if ($this->_id_field) {
         $arrCriteria["{$this->_id_field} <> ?"] = $this->_id;
     }
     $select = new Select($this->_tablename);
     $select->where($arrCriteria);
     $count = $this->_dao->select_count($select);
     if ($count) {
         $this->addException("Já existe um registro com este {$label}: {$value}");
     }
 }
Пример #7
0
 protected function validateToken($id, $v)
 {
     $select = new Select('admin');
     $select->addField('password_change_date');
     $select->where(array('id_admin = ?' => $id));
     $result = $this->_dao->select($select);
     if (!count($result)) {
         return $v->addException('Token inválido, por favor gere um novo link de recuperação');
     }
     $time_inicial = strtotime(date('Y-m-d'));
     $time_final = strtotime($result[0]['password_change_date']);
     $diferenca = $time_final - $time_inicial;
     $dias = (int) floor($diferenca / (60 * 60 * 24));
     if ($dias !== 0) {
         return $v->addException('Token expirado, por favor gere um novo link de recuperação');
     }
 }
Пример #8
0
 protected function getMaxSequence($arrCriteria)
 {
     $entity_tbl = $this->_entity->getTbl();
     $entity_sequence = $this->_entity->getSequence();
     $select = new Select($entity_tbl);
     if ($this->_entity->hasTrash()) {
         $arrCriteria['is_del = 0'] = null;
     }
     if (isset($entity_sequence['optional']) && $entity_sequence['optional']) {
         $arrCriteria['sequence > ?'] = '0';
     }
     $select->where($arrCriteria);
     return $this->_dao->select_count($select);
 }
Пример #9
0
 public function getTweets()
 {
     $entity_id = $this->_entity->getId();
     $entity_tbl = $this->_entity->getTbl();
     $select = new Select('tweet');
     $select->addField('date');
     $select->addField('msg');
     $select->inner_join('id_tweet', Select::construct("r_{$entity_tbl}_tweet"));
     $select->where(array("b.{$entity_id} = ?" => $this->getId()));
     $select->order_by('date DESC');
     $result = $this->_dao->select($select);
     return $result;
 }
Пример #10
0
 public function getById($id = null)
 {
     if ($id) {
         $this->setId($id);
     }
     $arrCriteria = array('a.' . $this->getIdName() . ' = ?' => $this->getId());
     $select = new Select($this->getTableName());
     $select->addAllFields();
     $select->where($arrCriteria);
     $this->onGetById($select);
     $result = $this->_dao->select($select);
     if (!count($result)) {
         throw new Exception('Registro não encontrado.');
     }
     return $result[0];
 }
Пример #11
0
 private function getIdByTitle($row)
 {
     $fe_tbl = $this->_foreign_entity->getTbl();
     $fe_id = $this->_foreign_entity->getId();
     $fe_title = $this->_foreign_entity->getTitle();
     $arrCriteria["{$fe_title} = ?"] = $row;
     $select = new Select($fe_tbl);
     $select->addField($fe_id, 'id');
     $select->where($arrCriteria);
     $result = $this->_dao->select($select);
     return count($result) ? $result[0]['id'] : false;
 }
Пример #12
0
 public function deleteChildrens(Entity $entity, $id, $tableHistory)
 {
     $entity_id = $entity->getId();
     $entity_tbl = $entity->getTbl();
     $children = $entity->getChildren();
     // verificia se é página infinita para deletar uma filha dela caso exista
     if (array_key_exists('id_parent', $tableHistory)) {
         $model = $entity->getModel();
         $select = new Select($entity_tbl);
         $select->addField($entity_id, 'id');
         $select->where(array('id_parent = ?' => $tableHistory[$entity_id]));
         $result = $this->_dao->select($select);
         $arr_delete = array();
         foreach ($result as $row) {
             $arr_delete[] = array('name' => $entity_tbl, 'id' => $row['id']);
         }
         $this->delete($arr_delete);
     }
     //
     foreach ($children as $child) {
         $child_entity = $this->_entities->getEntity($child);
         $child_tbl = $child_entity->getTbl();
         $child_id = $child_entity->getId();
         $select = new Select($child_tbl);
         $select->addField($child_id, 'id_children');
         $select->where(array($entity_id . ' = ? ' => $id));
         $result = $this->_dao->select($select);
         $arr_delete = array();
         foreach ($result as $row) {
             $arr_delete[] = array('name' => $child_tbl, 'id' => $row['id_children']);
         }
         $this->delete($arr_delete);
     }
 }