Beispiel #1
0
 public static function getPortfolioWithId($pid)
 {
     if (!$pid) {
         return null;
     }
     global $wpdb;
     $portfolio = null;
     $query = @$wpdb->prepare("SELECT * FROM " . CRP_TABLE_PORTFOLIOS . " WHERE id='{$pid}'");
     $res = $wpdb->get_results($query, OBJECT);
     if (count($res)) {
         $portfolio = $res[0];
         $query = @$wpdb->prepare("SELECT * FROM " . CRP_TABLE_PROJECTS . " WHERE pid='{$pid}'");
         $res = $wpdb->get_results($query, OBJECT);
         $projects = array();
         foreach ($res as $project) {
             $project->pics = explode(',', $project->pics);
             $project->categories = explode(',', $project->categories);
             $projects[$project->id] = $project;
         }
         $portfolio->projects = $projects;
         $portfolio->corder = explode(',', $portfolio->corder);
         if ($portfolio->options && !empty($portfolio->options)) {
             $portfolio->options = json_decode(base64_decode($portfolio->options), true);
         } else {
             $portfolio->options = json_decode(base64_decode(CRPHelper::getPortfolioDefaultOptions()), true);
         }
     }
     return $portfolio;
 }
Beispiel #2
0
 private function initializeTables()
 {
     global $wpdb;
     //Insert demo portfolio
     $wpdb->insert($this->tablePortfolios, array('title' => '', 'corder' => '', 'options' => CRPHelper::getPortfolioDefaultOptions()));
     $pid = $wpdb->insert_id;
     //Add demo project
     $wpdb->insert($this->tableProjects, array('pid' => $pid, 'title' => '', 'description' => ""));
 }