Faq::create PHP Méthode

create() public méthode

public create ( $postdata )
    public function create($postdata)
    {
        if ($this->user->getClass() < User::CLASS_ADMIN) {
            throw new Exception(L::get("PERMISSION_DENIED"), 401);
        }
        $sth = $this->db->prepare("INSERT INTO faq(type, question, answer, flag, categ, `order`) VALUES(?, ?, ?, ?, ?, ?)");
        $sth->bindParam(1, $postdata["type"], PDO::PARAM_STR);
        $sth->bindParam(2, $postdata["question"], PDO::PARAM_STR);
        $sth->bindParam(3, $postdata["answer"], PDO::PARAM_STR);
        $sth->bindParam(4, $postdata["flag"], PDO::PARAM_INT);
        $sth->bindParam(5, $postdata["categ"], PDO::PARAM_INT);
        $sth->bindParam(6, $postdata["order"], PDO::PARAM_INT);
        $sth->execute();
    }

Usage Example

Exemple #1
0
 public function run()
 {
     DB::table('faqs')->truncate();
     DB::table('faqs')->delete();
     for ($i = 0; $i < 20; $i++) {
         Faq::create(array('user_id' => '1', 'title' => 'Тестовый вопрос - ' . $i, 'content' => 'Тестовый ответ - ' . $i, 'active' => 1, 'meta_title' => 'Тестовый ответ мета заголовок - ' . $i, 'meta_description' => 'Тестовый вопрос мета описание - ' . $i, 'meta_keywords' => 'Тестовый вопрос ключевые слова - ' . $i, 'published_at' => '2015-01-28 16:50:01'));
     }
 }
All Usage Examples Of Faq::create