2016-11-04 18 views
2

私はPhalconフレームワークとPostgreSQL挿入配列

を使用して、私は、データベースの列の型に配列を挿入しよう:varchar[]

array(4) { [0]=> string(1) "1" [1]=> string(1) "6" [2]=> string(1) "9" [3]=> string(2) "12" } 

しかし、次のエラー取得:

SQLSTATEを[HY093]:無効なパラメータ番号:パラメータが定義されていません

ここでは、このしてください

+2

コードを共有してください。それ以上の文脈なしであなたを助けることは不可能です。 – Mureinik

+0

あなたの質問コードを表示 – Timothy

+0

Postgresでは、そのコードがどんなものかとはっきりしていませんが、 'array ['1'、 '6'、 '9'、 '12']' –

答えて

0

を修正するために私を助けてください、私のモデルである:

<?php 
namespace App\Models; 

use Phalcon\Mvc\Model; 
use Phalcon\Validation; 
use Phalcon\Validation\Validator\Uniqueness; 

class Document extends Model 
{ 

    public $id; 
    public $relatedocument; 

    public function getSource() 
    { 
     return "document"; 
    } 

=====フォーム======

<?php 
namespace App\Modules\Backend\Forms; 

use Idoc\Models\Document; 
use Phalcon\Forms\Form; 
use Phalcon\Forms\Element\Select; 

class DocumentForm extends Form 
{ 
    public function initialize($entity = null, $options = null) 
    { 
     $data = Document::find(); 
     $this->add(new Select('relatedocument[]', $data, [ 
      'using' => [ 
       'id', 
       'name' 
      ], 
      'useEmpty' => true, 
      'emptyText' => '....', 
      'multiple' => 'multiple', 
      'class' => 'form-control search-select' 
     ])); 
    } 

===== addAction ======

public function addAction() 
    { 
     if ($this->request->isPost()) { 
      $doc = new Document(); 
      $doc->relatedocument = $this->request->getPost('relatedocument'); 
      if (!$doc->save()) { 
      $this->flash->error($doc->getMessages()); 
      } else { 
       $this->flash->success("Văn bản đã được tạo"); 
       Tag::resetInput(); 
      }  
     } 
     $this->view->form = new DocumentForm(null); 
    } 
+0

[あなたの質問を更新してください](http://stackoverflow.com/posts/40421287/edit)。あなたの質問の下にある[編集](http://stackoverflow.com/posts/40421287/edit)ボタンを押してください。 – Timothy

+0

あなたのフォームにあなたの要素に 'relatedocument []'という名前を付けますが、あなたのコントローラでは 'relatedocument' – Timothy