select()->setIntegrityCheck(false); $select->from(array('a' => $this->_name), array('name', 'code', 'subdomain')) ->where('a.subdomain = ?', $subdomain); $rows = $this->fetchRow($select); return $rows; } public function findByIsdisabled($isdisabled){ $select = $this->select()->setIntegrityCheck(false); $select->from(array('a' => $this->_name), array('name', 'code', 'subdomain')) ->where('a.isdisabled = ?', $isdisabled); $rows = $this->fetchAll($select); return $rows; } }select()->setIntegrityCheck(false); // $select_untranslated->from(array('a' => $this->_name)) // ->where('a.status = ?', 'untranslated') // ->order('a.message ASC'); // $rowset_untranslated = $this->fetchAll($select_untranslated); // foreach ($rowset_untranslated as $row_untranslated) { // $row_untranslated->delete(); // } // /*GET TRANSLATED*/ // $select = $this->select()->setIntegrityCheck(false); // $select->from(array('a' => $this->_name)) // ->where('a.status = ?', 'translated') // ->order('a.message ASC'); // $rowset = $this->fetchAll($select); // /*CREATE MESSAGES TABLE TRANSLATIONS*/ // $messages = array(); // foreach($rowset as $row){ // $messages[$row->message][$row->locale] = $row; // } // /*POPULATE NEW TABLE*/ // foreach($messages as $message => $langs){ // $i = 0; $idlanguage_translate = null; $count = count($langs); // foreach($langs as $lang => $row){ // /*CREATE NEW LINE ON*/ // if($i == 0){ // $idlanguage_translate = $this->insert(array( // 'message' => $row->message, // 'status' => 'translated', // 'locale' => '' // )); // } // $language_translate_language->insert(array( // 'idlanguage_translate' => $idlanguage_translate, // 'lang' => $lang, // 'value' => $row->value, // 'status' => 'translated', // )); // $i++; // /*WHEN FINISHED WITH CURRENT MESSAGE, REMOVE DUPLICATE MESSAGE WITH != ID*/ // if($i == $count){ // $select_delete = $this->select()->setIntegrityCheck(false); // $select_delete->from(array('a' => $this->_name)) // ->where('a.message = ?', $row->message) // ->where('a.idlanguage_translate != ?', $idlanguage_translate); // $rowset_delete = $this->fetchAll($select_delete); // foreach ($rowset_delete as $row_delete) { // $row_delete->delete(); // } // } // } // } } public function insert(array $data){ $pk = parent::insert($data); $row = $this->fetchRow($pk); $cache = Zend_Registry::get('Majes_Translate'); $cache->clean(Zend_Cache::CLEANING_MODE_ALL); return $pk; } public function update(array $data, $where){ $count = parent::update($data, $where); $rows = $this->fetchAll($where); $cache = Zend_Registry::get('Majes_Translate'); $cache->clean(Zend_Cache::CLEANING_MODE_ALL); return $count; } public function delete($where){ $rows = $this->fetchAll($where); $count = parent::delete($where); $cache = Zend_Registry::get('Majes_Translate'); $cache->clean(Zend_Cache::CLEANING_MODE_ALL); return $count; } public function back($sort = false, $offset = false, $limit = false, $qtype = false, $query = false){ $select = $this->select()->setIntegrityCheck(false); $select->from(array('a' => $this->_name), array( new Zend_Db_Expr('SQL_CALC_FOUND_ROWS a.idlanguage_translate'), 'idlanguage_translate', 'message')) ->where('a.message != ?', ''); if($qtype) $select->where('a.'.$qtype.' like ?', '%'.$query.'%'); if($sort) $select->order($sort); if($limit) $select->limit($limit, $offset); $rowsAll = $this->fetchAll($select); $selectNb = $this->getAdapter()->fetchAll('SELECT FOUND_ROWS()'); $return = array(); $return['total'] = $selectNb[0]['FOUND_ROWS()']; $return['rows'] = $rowsAll; return $return; } public function findByLocale($locale){ $select = $this->select()->setIntegrityCheck(false); $select->from(array('a' => $this->_name), array('idlanguage_translate', 'message')) ->join(array('b' => 'language_translate_language'), 'a.idlanguage_translate = b.idlanguage_translate AND b.lang = \''.$locale.'\'', array('b.value', 'b.lang', 'b.status')); $rows = $this->fetchAll($select); return $rows->count() > 0 ? $rows : array(); } public function findByMessageAndLocale($message, $locale){ $cache = Zend_Registry::get('Majes_Translate'); $cached = $cache->load(str_replace('=', '_', md5($message)).'_'.$locale); if($cached) return $cached['row']; $select = $this->select()->setIntegrityCheck(false); $select->from(array('a' => $this->_name), array('idlanguage_translate', 'message')) ->join(array('b' => 'language_translate_language'), 'a.idlanguage_translate = b.idlanguage_translate AND b.lang = \''.$locale.'\'', array('b.value', 'b.lang', 'b.status')) ->where('a.message = ?', $message); $row = $this->fetchRow($select); if($row) $cache->save(array('row' => $row), str_replace('=', '_', md5($message)).'_'.$locale); return $row; } public function findByMessage($message){ $select = $this->select()->setIntegrityCheck(false); $select->from(array('a' => $this->_name), array('idlanguage_translate', 'message')) ->where('a.message = ?', $message); $row = $this->fetchRow($select); return $row; } public function findByIdAndLocale($idlanguage_translate, $locale){ $select = $this->select()->setIntegrityCheck(false); $select->from(array('a' => $this->_name), array('idlanguage_translate', 'message')) ->join(array('b' => 'language_translate_language'), 'a.idlanguage_translate = b.idlanguage_translate AND b.lang = \''.$locale.'\'', array('b.value', 'b.lang', 'b.status')) ->where('a.idlanguage_translate = ?', $idlanguage_translate); return $row = $this->fetchRow($select); } } class Language_Models_TranslateLanguage extends Zend_Db_Table_Abstract{ protected $_name = 'language_translate_language'; protected $_primary = array('idlanguage_translate', 'lang'); public function insert(array $data){ $pk = parent::insert($data); $row = $this->fetchRow($pk); $cache = Zend_Registry::get('Majes_Translate'); $cache->clean(Zend_Cache::CLEANING_MODE_ALL); return $pk; } public function update(array $data, $where){ $count = parent::update($data, $where); $rows = $this->fetchAll($where); $cache = Zend_Registry::get('Majes_Translate'); $cache->clean(Zend_Cache::CLEANING_MODE_ALL); return $count; } }