A Way To Use Dbtype And Ctypevalidator

Hi all,


  • A database without rules, and don’t have all information (dynamic database)

  • A import system with a ‘force’ possibility.

Actually we do something like this:



  $oModel = new DynamicModel;

  foreach($aCSVfield as $sFieldName=>$iFieldKey){

    $oModel->$sFieldName=$aLine[$iFieldKey];// I want to control validity








It’s ok but it can break if there are some bad value (CBDcommand failed).

First option is to use transaction, but then we don’t really use ‘force’ system.

Second option, is to assign attribute ONLY if $aLine[$iFieldKey] are on valid type .

Then something like this:

  foreach($aCSVfield as $sFieldName=>$iFieldKey){






I think i can use $dbType and CTypeValidator for someFunction but don’t found how to start here.

For example, in $dbType i have:

  • character varying(20)

  • timestamp without time zone

  • integer

etc …

I just want to know if there are some integrated solution in Yii ? Without rules !