Properties

$actsAs

$actsAs : array

use behaviors

Type

array

$validate

$validate : array

Validation rules

Type

array

$useDbConfig

$useDbConfig : string

Use database config

Type

string

$belongsTo

$belongsTo : array

belongsTo associations

Type

array

$hasMany

$hasMany : array

hasMany associations

Type

array

$__changeDbConfig

$__changeDbConfig : string

接続先DB master slave変更用

Type

string

$__oldSlaveDbConfig

$__oldSlaveDbConfig : string

接続先DB 古いslave保存用

Type

string

Methods

__construct()

__construct(boolean|integer|string|array  $id = false, string  $table = null, string  $ds = null) 

Constructor. Binds the model's database table to the object.

Parameters

boolean|integer|string|array $id

Set this ID for this model on startup, can also be an array of options, see above.

string $table

Name of database table to use.

string $ds

DataSource connection name.

setMasterDataSource()

setMasterDataSource() : void

Masterの接続先に変更する。

setSlaveDataSource()

setSlaveDataSource() : void

以前のSlaveの接続先に戻す。なければ、ランダムに選択

getDataSource()

getDataSource() : \DataSource

Gets the DataSource to which this model is bound.

Returns

\DataSource —

A DataSource object

create()

create(boolean|array  $data = array(), boolean  $filterKey = false) : array

NetCommonsで使用する共通の値がセットされた結果を返します。<br> CakePHPのSchemaは、not null指定されたカラムのdefaultがnullになっているため、<br> ''(長さ0の文字列)に書き換えています。<br> https://github.com/NetCommons3/NetCommons3/issues/7

セットされるデータ

'room_id' => Current::read('Room.id'),
'language_id' => Current::read('Language.id'),
'block_id' => Current::read('Block.id'),
'block_key' => Current::read('Block.key'),
'frame_id' => Current::read('Frame.id'),
'frame_key' => Current::read('Frame.key'),
'plugin_key' => Inflector::underscore($this->plugin),

Parameters

boolean|array $data

Optional data array to assign to the model after it is created. If null or false, schema data defaults are not merged.

boolean $filterKey

If true, overwrites any primary key input with an empty value

Returns

array —

The current Model::data; after merging $data and/or defaults from database

createAll()

createAll(boolean|array  $data = array(), boolean  $filterKey = false) : array

Initializes the model for writing a new record, loading the default values for those fields that are not defined in $data, and clearing previous validation errors.

Especially helpful for saving data in loops.

Parameters

boolean|array $data

Optional data array to assign to the model after it is created. If null or false, schema data defaults are not merged.

boolean $filterKey

If true, overwrites any primary key input with an empty value

Returns

array —

The current Model::data; after merging $data and/or defaults from database

begin()

begin() : void

transaction begin

commit()

commit() : void

transaction commit

rollback()

rollback(mixed  $ex = null) : void

transaction rollback

Parameters

mixed $ex

Exception

Throws

\Exception

loadModels()

loadModels(array  $models = array()) : void

Load models

Parameters

array $models

models to load

beforeValidate()

beforeValidate(array  $options = array()) : boolean

Called during validation operations, before validation. Please note that custom validation rules can be defined in $validate.

Parameters

array $options

Options passed from Model::save().

Returns

boolean —

True if validate operation should continue, false to abort

beforeSave()

beforeSave(array  $options = array()) : boolean

Called before each save operation, after validation. Return a non-true result to halt the save.

Parameters

array $options

Options passed from Model::save().

Returns

boolean —

True if the operation should continue, false if it should abort

afterFind()

afterFind(array  $results, boolean  $primary = false) : mixed

AfterFind Callback function

Parameters

array $results

found data records

boolean $primary

indicates whether or not the current model was the model that the query originated on or whether or not this model was queried as an association

Returns

mixed

getPeriodStatus()

getPeriodStatus(boolean  $check, string  $startTime, string  $endTime) : integer

getPeriodStatus get period status now and specified time

Parameters

boolean $check

flag data

string $startTime

start time

string $endTime

end time

Returns

integer

afterFrameSave()

afterFrameSave(array  $data) : mixed

After frame save hook

このルームにすでに小テストブロックが存在した場合で、かつ、現在フレームにまだブロックが結びついてない場合、 すでに存在するブロックと現在フレームを結びつける

Parameters

array $data

received post data

Throws

\InternalErrorException

Returns

mixed —

On success Model::$data if its not empty or true, false on failure

getQuizzesList()

getQuizzesList(array  $conditions, array  $options = array()) : array

getQuizzesList get quizzes by specified block id and specified user id limited number

Parameters

array $conditions

find condition

array $options

検索オプション

Returns

array

getBaseCondition()

getBaseCondition(array  $addConditions = array()) : array

get index sql condition method

Parameters

array $addConditions

追加条件

Returns

array

getCondition()

getCondition(array  $addConditions = array()) : array

get index sql condition method

Parameters

array $addConditions

追加条件

Returns

array

hasPublished()

hasPublished(array  $quiz) : integer

hasPublished method

Parameters

array $quiz

quiz data

Returns

integer

saveQuiz()

saveQuiz(  $quiz) : boolean

saveQuiz save Quiz data

Parameters

$quiz

Throws

\InternalErrorException

Returns

boolean

clearQuizId()

clearQuizId(  $quiz) : void

clearQuizId 小テストデータからIDのみをクリアする

Parameters

$quiz

_getDefaultValue()

_getDefaultValue() : array

全カラムのデフォルト値をセットした配列を返す。

Returns

array —

デフォルト値をセットした配列

_getPeriodConditions()

_getPeriodConditions() : array

時限公開のconditionsを返す

Returns

array

_saveBlock()

_saveBlock(array  $frame) : boolean

save block

afterFrameSaveやsaveQuestionnaireから呼び出される

Parameters

array $frame

frame data

Throws

\InternalErrorException

Returns

boolean

__getRandomlySlave()

__getRandomlySlave() : string

Find the slaves we have

Returns

string —

The name of the DataSource, as defined in app/Config/database.php

__changeDataSource()

__changeDataSource() : void

MasterDBに切り替える処理