tableName() public method

public tableName ( ) : string
return string the associated database table name
示例#1
0
文件: Article.php 项目: oakcms/oakcms
 public function api_items($options = [])
 {
     if (!$this->_items) {
         $this->_items = [];
         $query = ContentArticles::find()->with('translations')->status(ContentArticles::STATUS_PUBLISHED);
         if (!empty($options['where'])) {
             $query->andFilterWhere($options['where']);
         }
         if (!empty($options['tags'])) {
             $query->innerJoinWith('tags', false)->andWhere([Tag::tableName() . '.name' => (new Item())->filterTagValues($options['tags'])])->addGroupBy('item_id');
         }
         if (!empty($options['orderBy'])) {
             $query->orderBy($options['orderBy']);
         } else {
             $query->sortDate();
         }
         $this->_adp = new ActiveDataProvider(['query' => $query, 'pagination' => !empty($options['pagination']) ? $options['pagination'] : []]);
         foreach ($this->_adp->models as $model) {
             $this->_items[] = new ArticleObject($model);
         }
     }
     return $this->_items;
 }
示例#2
0
 public static function getObject($source_id)
 {
     $connect = new PDO('mysql:host=localhost;dbname=blog', 'root', '4fhc9imz');
     $statement_text = $connect->prepare("SELECT post FROM " . self::tableName() . " WHERE id=?");
     $statement_text->execute(array("{$source_id}"));
     //var_dump($statement_text);
     $re_text = $statement_text->fetch();
     $statement_tagids = $connect->prepare("SELECT tag_id FROM posttotag WHERE post_id=?");
     $statement_tagids->execute(array("{$source_id}"));
     $re_tagid = $statement_tagids->fetchAll();
     foreach ($re_tagid as $tagid) {
         $tagid_value = $tagid['tag_id'];
         $statement_tags = $connect->prepare("SELECT tag FROM " . Tag::tableName() . " WHERE id=?");
         $statement_tags->execute(array($tagid_value));
         $re_tags = $statement_tags->fetch();
         $tag_names = $re_tags['tag'];
         $pure_tag[] = ['id' => $tagid_value, 'name' => $tag_names];
         //minden lefutáskor fölülíródik
     }
     $rc_post = new Post(['text' => $re_text, 'tags' => $pure_tag, 'id' => $source_id]);
     //var_dump ($rc_post);
     return $rc_post;
     //ha ennek nem adok return value-t akkor a getallposts nem kapja meg amit kell.
 }