當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Topic::create方法代碼示例

本文整理匯總了PHP中Topic::create方法的典型用法代碼示例。如果您正苦於以下問題:PHP Topic::create方法的具體用法?PHP Topic::create怎麽用?PHP Topic::create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Topic的用法示例。


在下文中一共展示了Topic::create方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: beforeSave

 public function beforeSave($options = array())
 {
     //parent::beforeSave($options);
     //print_r($this->data);
     $loggedInUser = AuthComponent::user();
     $found = false;
     $userId = $loggedInUser['user_id'];
     $this->data['Post']['post_by'] = $userId;
     $this->data['Post']['post_date'] = (new DateTime())->format('Y-m-d');
     //format('Y-m-d H:i:s')
     if (!empty($this->data['Topic']['topic_subject'])) {
         $str = $this->data['Topic']['topic_subject'];
         $num = $this->data['Post']['post_cat'];
         $subject = new Topic();
         $found = $subject->find('first', array('conditions' => array('Topic.topic_subject LIKE' => $str, 'Topic.topic_cat =' => $num)));
         if (!$found) {
             $subject->create();
             //create topic
             $subject->save(array('topic_subject' => $this->data['Topic']['topic_subject'], 'topic_date' => (new DateTime())->format('Y-m-d'), 'topic_cat' => $this->data['Post']['post_cat'], 'topic_by' => $userId));
             //see also save associated model method cakephp
             $this->data['Post']['post_topic'] = $this->Topic->getLastInsertId();
             return true;
         }
         $this->data['Post']['post_topic'] = $found['Topic']['topic_id'];
         return true;
     }
     //nothing
     return true;
 }
開發者ID:s3116979,項目名稱:BulletinBoard,代碼行數:29,代碼來源:Post.php

示例2: run

 public function run()
 {
     $faker = Faker\Factory::create();
     for ($i = 0; $i < 50; $i++) {
         $new = Topic::create(array('author' => $faker->name, 'title' => $faker->sentence(10), 'message' => $faker->paragraphs(2, true), 'place' => $faker->randomElement(array('web', 'api')), 'updated_at' => $faker->dateTime('now'), 'created_at' => $faker->dateTime('now')));
     }
 }
開發者ID:roffjump,項目名稱:forum,代碼行數:7,代碼來源:TopicTableSeeder.php

示例3: handle_request

function handle_request()
{
    # GET params
    $topic_name = $_POST['topic_name'];
    $topic_desc = $_POST['topic_desc'];
    $resource_name = $_POST['resource_name'];
    $resource_desc = $_POST['resource_desc'];
    $resource_uri = $_POST['resource_uri'];
    $resource_type = $_POST['resource_type'];
    #echo($topic_name);
    # PROCESS request
    Topic::create($topic_name, $topic_desc, $resource_name, $resource_desc, $resource_uri, $resource_type);
    header("location: list.php");
}
開發者ID:CarlosGabaldon,項目名稱:you-learn,代碼行數:14,代碼來源:add.php

示例4: run

 public function run()
 {
     $faker = Faker::create();
     $users = User::lists('id');
     $nodes = Node::lists('id');
     foreach (range(1, 50) as $index) {
         Topic::create(['user_id' => $faker->randomElement($users), 'node_id' => $faker->randomElement($nodes), 'title' => $faker->sentence(), 'body' => $faker->text(), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString()]);
     }
     foreach (range(1, 50) as $index) {
         Topic::create(['user_id' => $faker->randomElement($users), 'node_id' => $faker->randomElement($nodes), 'title' => $faker->sentence(), 'body' => $faker->text(), 'is_excellent' => true, 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString()]);
     }
     foreach (range(1, 30) as $index) {
         Topic::create(['user_id' => $faker->randomElement($users), 'node_id' => $faker->randomElement($nodes), 'title' => $faker->sentence(), 'body' => $faker->text(), 'is_wiki' => true, 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString()]);
     }
     foreach (range(1, 100) as $index) {
         Topic::create(['user_id' => 1, 'node_id' => $faker->randomElement($nodes), 'title' => $faker->sentence(), 'body' => $faker->text(), 'created_at' => Carbon::now()->toDateTimeString(), 'updated_at' => Carbon::now()->toDateTimeString()]);
     }
 }
開發者ID:bobken,項目名稱:phphub,代碼行數:18,代碼來源:TopicsTableSeeder.php

示例5: transfer_topics_3_5

function transfer_topics_3_5($p_parentId = 0)
{
    global $g_ado_db;
    $sql = 'SELECT * FROM TopicsOld';
    if (!is_null($p_parentId)) {
        $sql .= " WHERE ParentId = {$p_parentId}";
    }
    $sql .= ' ORDER BY TopicOrder DESC, LanguageId ASC';
    $rows = $g_ado_db->GetAll($sql);
    foreach ($rows as $row) {
        $topic = new Topic($row['Id']);
        if ($topic->exists()) {
            $topic->setName($row['LanguageId'], $row['Name']);
        } else {
            $topic->create(array('parent_id' => $p_parentId, 'names' => array($row['LanguageId'] => $row['Name'])));
            transfer_topics_3_5($topic->getTopicId());
        }
    }
}
開發者ID:nidzix,項目名稱:Newscoop,代碼行數:19,代碼來源:transfer_topics.php

示例6: require_once

 require_once(INCLUDE_DIR.'class.topic.php');
 $do=strtolower($_POST['do']);
 switch($do){
     case 'update':
         $topic = new Topic($_POST['topic_id']);
         if($topic && $topic->getId()) {
             if($topic->update($_POST,$errors))
                 $msg='Topic updated successfully';
             elseif(!$errors['err'])
                 $errors['err']='Error updating the topic';
         }else{
             $errors['err']='Internal error';
         }
         break;
     case 'create':
         if(Topic::create($_POST,$errors))
             $msg='Help topic created successfully';
         elseif(!$errors['err'])
             $errors['err']='Unable to create the topic. Internal error';
         break;
     case 'mass_process':
         if(!$_POST['tids'] || !is_array($_POST['tids'])) {
             $errors['err']='You must select at least one topic';
         }else{
             $count=count($_POST['tids']);
             $ids=implode(',',$_POST['tids']);
             if($_POST['enable']){
                 $sql='UPDATE '.TOPIC_TABLE.' SET isactive=1, updated=NOW() WHERE topic_id IN ('.$ids.') AND isactive=0 ';
                 if(db_query($sql) && ($num=db_affected_rows()))
                     $msg="$num of $count selected services enabled";
                 else
開發者ID:hungnv0789,項目名稱:vhtm,代碼行數:31,代碼來源:admin.php

示例7: array

$errorMsgs = array();
if (empty($f_topic_name)) {
	$correct = false;
	$errorMsgs[] = getGS('You must fill in the $1 field.','<B>'.getGS('Name').'</B>');
}
if ($f_topic_language_id <= 0) {
	$correct = false;
	$errorMsgs[] = getGS('You must choose a language for the topic.');
}

if (!empty($f_topic_name)) {
	if ($f_topic_id == 0) {
		// Create new topic
		$topic = new Topic();
		$created = $topic->create(array('parent_id' => $f_topic_parent_id,
		'names'=>array($f_topic_language_id=>$f_topic_name)));
	} else {
		// Translate existing topic
		$topic = new Topic($f_topic_id);
		$created = $topic->setName($f_topic_language_id, $f_topic_name);
	}
	if ($created) {
		camp_html_goto_page("/$ADMIN/topics/index.php");
	} else {
		$errorMsgs[] = getGS('The topic name is already in use by another topic.');
	}
} else {
	$errorMsgs[] = getGS('You must fill in the $1 field.','<B>'.getGS('Name').'</B>');
}

$crumbs = array();
開發者ID:nistormihai,項目名稱:Newscoop,代碼行數:31,代碼來源:do_add.php

示例8: sprintf

if ($_REQUEST['id'] && !($topic = Topic::lookup($_REQUEST['id']))) {
    $errors['err'] = sprintf(__('%s: Unknown or invalid ID.'), __('help topic'));
}
if ($_POST) {
    switch (strtolower($_POST['do'])) {
        case 'update':
            if (!$topic) {
                $errors['err'] = sprintf(__('%s: Unknown or invalid'), __('help topic'));
            } elseif ($topic->update($_POST, $errors)) {
                $msg = sprintf(__('Successfully updated %s'), __('this help topic'));
            } elseif (!$errors['err']) {
                $errors['err'] = sprintf(__('Error updating %s. Try again!'), __('this help topic'));
            }
            break;
        case 'create':
            if ($id = Topic::create($_POST, $errors)) {
                $msg = sprintf(__('Successfully added %s'), Format::htmlchars($_POST['topic']));
                $_REQUEST['a'] = null;
            } elseif (!$errors['err']) {
                $errors['err'] = sprintf(__('Unable to add %s. Correct error(s) below and try again.'), __('this help topic'));
            }
            break;
        case 'mass_process':
            switch (strtolower($_POST['a'])) {
                case 'sort':
                    // Pass
                    break;
                default:
                    if (!$_POST['ids'] || !is_array($_POST['ids']) || !count($_POST['ids'])) {
                        $errors['err'] = sprintf(__('You must select at least %s'), __('one help topic'));
                    }
開發者ID:dmiguel92,項目名稱:osTicket-1.8,代碼行數:31,代碼來源:helptopics.php

示例9: Topic

<?php 
//Create Topic Object
$topic = new Topic();
if (isset($_POST['do_create'])) {
    //Create Validator Object
    $validate = new Validator();
    //Create Data Array
    $data = array();
    $data['title'] = $_POST['title'];
    $data['body'] = $_POST['body'];
    $data['category_id'] = $_POST['category'];
    $data['user_id'] = getUser()['user_id'];
    $data['last_activity'] = date("Y-m-d H:i:s");
    //Required Fields
    $field_array = array('title', 'body', 'category');
    if ($validate->isRequired($field_array)) {
        //Register User
        if ($topic->create($data)) {
            redirect('index.php', 'Your topic has been posted', 'success');
        } else {
            redirect('topic.php?id=' . $topic_id, 'Something went wrong with your post', 'error');
        }
    } else {
        redirect('create.php', 'Please fill in all required fields', 'error');
    }
}
//Get Template & Assign Vars
$template = new Template('templates/create.php');
//Assign Vars
//Display template
echo $template;
開發者ID:XybzZ,項目名稱:Udemy-Projects,代碼行數:31,代碼來源:create.php

示例10: run

 public function run()
 {
     Topic::create(['user_id' => 1, 'title' => '戲劇人生,人生戲劇', 'content' => '戲劇的道路很長很長,多久才能走完,我曾經這樣的問我,路在何方,在何方,其實沒有荊棘的道路該有多淒涼']);
     Topic::create(['user_id' => 2, 'title' => '戲劇人生,人生戲劇', 'content' => '戲劇的道路很長很長,多久才能走完,我曾經這樣的問我,路在何方,在何方,其實沒有荊棘的道路該有多淒涼']);
 }
開發者ID:Jv-Juven,項目名稱:opera-1,代碼行數:5,代碼來源:TopicsTableSeeder.php

示例11: createAndTest

	private function createAndTest($p_topicId, $p_data, $p_left, $p_right)
	{
		$topic = new Topic($p_topicId);
		$topic->create($p_data);
		unset($topic);
		$topic = new Topic($p_topicId);
		$this->assertTrue($topic->exists());
		foreach ($p_data['names'] as $languageId=>$name) {
			$this->assertEquals($name, $topic->getName($languageId));
		}
		$this->assertEquals($p_left, $topic->getLeft());
		$this->assertEquals($p_right, $topic->getRight());
	}
開發者ID:nistormihai,項目名稱:Newscoop,代碼行數:13,代碼來源:TopicTest.php

示例12: run

 public function run()
 {
     $i = 0;
     for ($i == 0; $i < 50; $i++) {
         Topic::create(['title' => '這裏是主題主題' . $i, 'content' => '安裝完 Laravel 之後,首先需要做的事情就是為你的應用程序設置一個隨機字符串作為整個應用的 key(用於加密)。如果你是通過 Composer 安裝的 Laravel,這個 key 可能已經通過 key:generate 指令自動為你設置好了。', 'topic_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/100kuai0-01.jpg', 'scan_num' => rand(1111, 4444), 'focus_num' => rand(1111, 8888)]);
     }
     // Topic::create([
     // 	'title'=>'這裏是主題主題1',
     // 	'content' => '安裝完 Laravel 之後,首先需要做的事情就是為你的應用程序設置一個隨機字符串作為整個應用的 key(用於加密)。如果你是通過 Composer 安裝的 Laravel,這個 key 可能已經通過 key:generate 指令自動為你設置好了。',
     // 	'topic_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/100kuai0-01.jpg',
     // 	'scan_num' => '19289',
     // 	'focus_num' => '2828'
     // ]);
     // Topic::create([
     // 	'title'=>'這裏是主題主題2',
     // 	'content' => '安裝完 Laravel 之後,首先需要做的事情就是為你的應用程序設置一個隨機字符串作為整個應用的 key(用於加密)。如果你是通過 Composer 安裝的 Laravel,這個 key 可能已經通過 key:generate 指令自動為你設置好了。',
     // 	'topic_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/100kuai0-01.jpg',
     // 	'scan_num' => '19289',
     // 	'focus_num' => '2828'
     // ]);
     // Topic::create([
     // 	'title'=>'這裏是主題主題3',
     // 	'content' => '安裝完 Laravel 之後,首先需要做的事情就是為你的應用程序設置一個隨機字符串作為整個應用的 key(用於加密)。如果你是通過 Composer 安裝的 Laravel,這個 key 可能已經通過 key:generate 指令自動為你設置好了。',
     // 	'topic_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/100kuai0-01.jpg',
     // 	'scan_num' => '19289',
     // 	'focus_num' => '2828'
     // ]);
     // Topic::create([
     // 	'title'=>'這裏是主題主題4',
     // 	'content' => '安裝完 Laravel 之後,首先需要做的事情就是為你的應用程序設置一個隨機字符串作為整個應用的 key(用於加密)。如果你是通過 Composer 安裝的 Laravel,這個 key 可能已經通過 key:generate 指令自動為你設置好了。',
     // 	'topic_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/100kuai0-01.jpg',
     // 	'scan_num' => '19289',
     // 	'focus_num' => '2828'
     // ]);
     // Topic::create([
     // 	'title'=>'這裏是主題主題5',
     // 	'content' => '安裝完 Laravel 之後,首先需要做的事情就是為你的應用程序設置一個隨機字符串作為整個應用的 key(用於加密)。如果你是通過 Composer 安裝的 Laravel,這個 key 可能已經通過 key:generate 指令自動為你設置好了。',
     // 	'topic_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/100kuai0-01.jpg',
     // 	'scan_num' => '19289',
     // 	'focus_num' => '2828'
     // ]);
     // Topic::create([
     // 	'title'=>'這裏是主題主題6',
     // 	'content' => '安裝完 Laravel 之後,首先需要做的事情就是為你的應用程序設置一個隨機字符串作為整個應用的 key(用於加密)。如果你是通過 Composer 安裝的 Laravel,這個 key 可能已經通過 key:generate 指令自動為你設置好了。',
     // 	'topic_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/100kuai0-01.jpg',
     // 	'scan_num' => '19289',
     // 	'focus_num' => '2828'
     // ]);
     // Topic::create([
     // 	'title'=>'這裏是主題主題7',
     // 	'content' => '安裝完 Laravel 之後,首先需要做的事情就是為你的應用程序設置一個隨機字符串作為整個應用的 key(用於加密)。如果你是通過 Composer 安裝的 Laravel,這個 key 可能已經通過 key:generate 指令自動為你設置好了。',
     // 	'topic_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/100kuai0-01.jpg',
     // 	'scan_num' => '19289',
     // 	'focus_num' => '2828'
     // ]);
     // Topic::create([
     // 	'title'=>'這裏是主題主題8',
     // 	'content' => '安裝完 Laravel 之後,首先需要做的事情就是為你的應用程序設置一個隨機字符串作為整個應用的 key(用於加密)。如果你是通過 Composer 安裝的 Laravel,這個 key 可能已經通過 key:generate 指令自動為你設置好了。',
     // 	'topic_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/100kuai0-01.jpg',
     // 	'scan_num' => '19289',
     // 	'focus_num' => '2828'
     // ]);
     // Topic::create([
     // 	'title'=>'這裏是主題主題9',
     // 	'content' => '安裝完 Laravel 之後,首先需要做的事情就是為你的應用程序設置一個隨機字符串作為整個應用的 key(用於加密)。如果你是通過 Composer 安裝的 Laravel,這個 key 可能已經通過 key:generate 指令自動為你設置好了。',
     // 	'topic_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/100kuai0-01.jpg',
     // 	'scan_num' => '19289',
     // 	'focus_num' => '2828'
     // ]);
     // Topic::create([
     // 	'title'=>'這裏是主題主題10',
     // 	'content' => '安裝完 Laravel 之後,首先需要做的事情就是為你的應用程序設置一個隨機字符串作為整個應用的 key(用於加密)。如果你是通過 Composer 安裝的 Laravel,這個 key 可能已經通過 key:generate 指令自動為你設置好了。',
     // 	'topic_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/100kuai0-01.jpg',
     // 	'scan_num' => '19289',
     // 	'focus_num' => '2828'
     // ]);
     // Topic::create([
     // 	'title'=>'這裏是主題主題11',
     // 	'content' => '安裝完 Laravel 之後,首先需要做的事情就是為你的應用程序設置一個隨機字符串作為整個應用的 key(用於加密)。如果你是通過 Composer 安裝的 Laravel,這個 key 可能已經通過 key:generate 指令自動為你設置好了。',
     // 	'topic_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/100kuai0-01.jpg',
     // 	'scan_num' => '19289',
     // 	'focus_num' => '2828'
     // ]);
     // Topic::create([
     // 	'title'=>'這裏是主題主題12',
     // 	'content' => '安裝完 Laravel 之後,首先需要做的事情就是為你的應用程序設置一個隨機字符串作為整個應用的 key(用於加密)。如果你是通過 Composer 安裝的 Laravel,這個 key 可能已經通過 key:generate 指令自動為你設置好了。',
     // 	'topic_url' => 'http://7xl6gj.com1.z0.glb.clouddn.com/100kuai0-01.jpg',
     // 	'scan_num' => '19289',
     // 	'focus_num' => '2828'
     // ]);
 }
開發者ID:Jv-Juven,項目名稱:gift,代碼行數:91,代碼來源:TopicsTableSeeder.php

示例13: add

 /**
  * Create a new topic staticaly .
  *
  * The values array may have the following keys:
  * - parent_id - parent topic identifier
  * - node_left
  * - node_right
  * - names - array of topic translations of the form: language_id => name
  *
  * @param array $p_values
  * @return json object
  */
 public static function add($p_values = null)
 {
     $return = array();
     $created = false;
     if (!is_array($p_values)) {
         $p_values = array();
     }
     $noName = FALSE;
     if (!array_key_exists('f_topic_name', $p_values)) {
         $noName = TRUE;
     } else {
         if (strlen($p_values['f_topic_name']) == 0) {
             $noName = TRUE;
         }
     }
     if ($noName) {
         $return['status'] = 0;
         $return['messageClass'] = 'error';
         $return['message'] = getGS('You must fill in the $1 field.', '<B>' . getGS('Name') . '</B>');
     } else {
         $f_topic_parent_id = array_key_exists('f_topic_parent_id', $p_values) ? $p_values['f_topic_parent_id'] : 0;
         $f_topic_language_id = array_key_exists('f_language_selected', $p_values) ? $p_values['f_language_selected'] : 1;
         $f_topic_name = trim($p_values['f_topic_name']);
         $topicParent = new Topic($f_topic_parent_id);
         $topic = new Topic();
         $created = $topic->create(array('parent_id' => $f_topic_parent_id, 'names' => array($f_topic_language_id => $f_topic_name)));
         if ($created) {
             $return['status'] = 1;
             $return['messageClass'] = 'highlight';
             $return['message'] = getGS('Topic created');
         } else {
             $return['status'] = 0;
             $return['messageClass'] = 'error';
             $return['message'] = getGS('The topic name is already in use by another topic.');
         }
     }
     return json_encode($return);
 }
開發者ID:nidzix,項目名稱:Newscoop,代碼行數:50,代碼來源:Topic.php

示例14: run

 public function run()
 {
     DB::table('topics')->delete();
     Topic::create(array('title' => 'How to use Chatterr', 'content' => 'Welcome to Chatterr, we hope you enjoy your stay', 'user_id' => 1, 'category_id' => 1));
     Topic::create(array('title' => 'Why Doge Is The Greatest Thing Ever', 'content' => 'We like dogs, but so do you. Go Doge!', 'user_id' => 1, 'category_id' => 2));
 }
開發者ID:vinamilvinamil,項目名稱:chatterr,代碼行數:6,代碼來源:DatabaseSeeder.php


注:本文中的Topic::create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。