Ejemplo n.º 1
0
 protected function _multiDelete($id)
 {
     $query = new Daq_Db_Query();
     $total = $query->select("COUNT(*) AS cnt")->from("Wpjb_Model_Job")->where("job_type = ?", $id)->fetchColumn();
     if ($total > 0) {
         $err = __("Cannot delete job type identified by ID #{id}. There are still jobs using this type.", WPJB_DOMAIN);
         $err = str_replace("{id}", $id, $err);
         $this->view->_flash->addError($err);
         return false;
     }
     try {
         $model = new Wpjb_Model_JobType($id);
         $model->delete();
         return true;
     } catch (Exception $e) {
         // log error
         return false;
     }
 }
Ejemplo n.º 2
0
 protected static function _getJobTypeId($title)
 {
     $slug = sanitize_title_with_dashes($title);
     $query = new Daq_Db_Query();
     $result = $query->select("*")->from("Wpjb_Model_JobType t")->where("t.title LIKE ?", "%" . $title . "%")->orWhere("t.slug LIKE ?", "%" . $slug . "%")->execute();
     if (count($result) > 0) {
         $jobType = $result[0];
         return $jobType->getId();
     } else {
         $jobType = new Wpjb_Model_JobType();
         $jobType->title = $title;
         $jobType->slug = $slug;
         $jobType->save();
         return $jobType->getId();
     }
 }