問題タブ [yii-cmodel]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
php - CSV アップロードに関する問題
Yii フレームワークを使用して CSV ファイルをアップロードしようとしています。以下のコードを追加しました:
モデル
見る(index.php)
コントローラ
このコードで直面している問題:
$line
のインスタンスであるためImport
、オブジェクトの要素を使用できるはず$line
ですが、それができません。私はこれを使用$line->'name'
しましたが、次のエラーが発生しました: 解析エラー: 構文エラー、予期しない ''名前'' (T_CONSTANT_ENCAPSED_STRING)、識別子 (T_STRING) または変数 (T_VARIABLE) または '{' または '$' が必要です$line
はここにあるので、ステートメントmodel
の最初の引数として配置できるはずです。activeTextField
このエラーが発生します: get_class() は、パラメーター 1 がオブジェクトであると想定しています。第三に、このコードはテキスト フィールドの同じ行を 5 回生成するため、コード内の代わりに を
activeTextField
配置し、ループ内でインクリメントすることで実験することを考えました。これにより、2 と同じエラーが発生します。$i
0
foreach
よろしく
yii - 制限のある Yii 関係をブラウズする
私はCommunity
モデルとモデルを持っていContent
ます。それぞれContent
にcommunity_id
柱があります。この単純な関係を作成しました。
(順序に注意してください)
上位 20 のコンテンツを表示しCommunityController
たい場合 (次に、別の ajax アクションで次の 20 を取得します。心配する必要はありません)。
おそらく、次のような基準を介して行うことができます。
しかし、コードはやり過ぎ (長すぎる) に見え、作成した Relation をまったく使用していないように感じます。もっと簡単な方法はありますか?それとも、ない問題を探していますか?
php - Yii 結合されたモデルの属性を返す
Yii には、場所に関連付けられたメディアがあります。私はそのように設定された関係を持っています:
パブリック関数関係() {
クエリを実行するときは、'with' ステートメントを使用してテーブルを結合します。
そして、データを json オブジェクトに入れて、CJSON 応答として返します。
問題は、返されるフィールドがメディアである親モデルのみからのものであり、結合されたモデルである場所からのものではないことです。私の質問は、親モデルと結合されたモデルの両方の結果を Yii で表示するにはどうすればよいですか?
php - Yiiコマンドラインはモデルを自動ロードしません
Yiiを使用してコマンドラインでコマンドを実行しようとしています。私のメソッドにはモデルが必要ですが、コマンドを実行すると、Yiiは、モデルが自動ロードされていないかのように、モデルが存在しないと言います。私のクラスはかなり短くてシンプルです:
エラーメッセージは次のようになります。
Yiiにモデルを自動ロードさせるために私がしなければならない特別なことはありますか?
php - Yii: 2 models with the same code for beforeValidate
I have a Yii app, and within 2 of the models, I have the code for the beforeValidation method.
Does yii have a solution for this, or should I create a component and use parameters for this common code?
php - Yii プロジェクト: (親) モデルの関連モデル (子) をロードしないようにするにはどうすればよいですか?
サラム (こんにちは)、(親) モデルの関連モデル (子) をロードしないようにするにはどうすればよいですか?
php - Yii - Include field from another model
my question consists of two parts:
1, I'm developing small ticketing software for technical support. I have model and views for Workorder (type of ticket). I would like to include another model's
field/input
into this model. This model
is called WorkorderJournalUpdate
. It's basicly just table with 3 rows:
*id, workorder_id, text*
. In this case, "workorder_id"
is in HAS_MANY
relation with "workorder_id
" in Workorder model/table
.
The reason why I want to include this field/model
is to create unique journal record after each Workorder update, so it looks like this:
http://luzer.eu/pu_files/27844_RelationsTC.jpg
//Edit: It would be great, if I could add new journal entry on each page update and as well read all previous records.
2, this part of my question is simple. I would like to make rule in model to make certain fields required, but only if other field is filled in. For example:
If Order ID
is not filled in, Ordered by should not be required. If Ordered by is filled in and Order ID
is not, Order ID
should be required
. Is this possible with "required
on" rule
?
This is all, hopefully, somebody will be able to help me. Thank you in advance!