私は CodeIgniter を初めて使用し、複数のモデルで使用するこの関数を持っています。
// Returns TRUE if the array of values supplied
// each correspond to a column in the database table.
// Else returns the value of the bad column.
private function _columns_exist( $columns, $table ) {
foreach( $columns as $key => $value ) {
if( !$this->db->field_exists( $key, $table ) ) {
return $key;
}
}
return TRUE;
}
関数を一度書き、それを多くの異なるファイルから再利用する正しい方法と考えられるものは何ですか?
この 1 つの機能のためだけにライブラリ全体を作成しますか?