Example #1
0
 /**
  *  コンストラクタ
  *
  *  @param  Cascade_DB_Criteria  データ抽出条件
  */
 public function __construct(Cascade_DB_Criteria $criteria)
 {
     parent::__construct();
     if ($criteria->df_name === NULL) {
         $ex_msg = 'Not found DataFormat Name in Criteria {criteria} %s';
         $ex_msg = sprintf($ex_msg, Cascade_System_Util::export($criteria, TRUE));
         throw new Cascade_Exception_DBException($ex_msg);
     }
     $this->data_format = Cascade::getDataFormat($criteria->df_name);
     $this->criteria = $criteria;
 }
Example #2
0
 /**
  *  ログ情報を文字列に展開する
  *
  *  @param   mixed   ログ情報
  *  @retrun  string  ログメッセージ
  */
 protected final function extract_message($input)
 {
     $output_str = '';
     switch (gettype($input)) {
         case 'array':
             $output_str = Cascade_System_Util::export($input, TRUE);
             break;
         case 'object':
             if (method_exists($input, 'getMessage')) {
                 $output_str = $input->getMessage();
             } else {
                 if (method_exists($input, 'toString')) {
                     $output_str = $input->toString();
                 } else {
                     if (method_exists($input, '__tostring')) {
                         $output_str = (string) $input;
                     } else {
                         $output_str = Cascade_System_Util::export($input, TRUE);
                     }
                 }
             }
             break;
         default:
             $output_str = (string) $input;
             break;
     }
     return $output_str;
 }
Example #3
0
 /**
  *  バインド変数値を内部変数に追加する
  *
  *  クエリー文字列に定義されている疑問符プレースホルダに、<br/>
  *  先頭のポジションからバインドする値を設定していく。<br/>
  *  変換可能な型
  *   - {@link VAR_TYPE_IS_NULL}
  *   - {@link VAR_TYPE_IS_BOOL}
  *   - {@link VAR_TYPE_IS_LONG}
  *   - {@link VAR_TYPE_IS_DOUBLE}
  *   - {@link VAR_TYPE_IS_STRING}
  *
  *  @param  mixed  バインド変数値
  *  @param  int    (optional) 指定の変数型に変換する場合に指定
  */
 protected function addBindValue($value, $type = self::VAR_TYPE_IS_STRING)
 {
     // Z_TYPEの取得
     $orig = $value;
     $orig_type = gettype($value);
     // 指定の型に変換
     switch ($type) {
         case self::VAR_TYPE_IS_NULL:
         case self::VAR_TYPE_IS_BOOL:
         case self::VAR_TYPE_IS_LONG:
         case self::VAR_TYPE_IS_DOUBLE:
             settype($value, $type);
             break;
         case self::VAR_TYPE_IS_STRING:
             switch ($orig_type) {
                 case self::VAR_TYPE_IS_NULL:
                     $value = 'NULL';
                     break;
                 case self::VAR_TYPE_IS_BOOL:
                     $value = $value ? '1' : '0';
                     break;
                 case self::VAR_TYPE_IS_LONG:
                 case self::VAR_TYPE_IS_DOUBLE:
                 case self::VAR_TYPE_IS_STRING:
                     settype($value, $type);
                     break;
                 default:
                     $str_value = Cascade_System_Util::export($value, TRUE);
                     $ex_msg = 'Invalid Z_TYPE of bind-value {z_type, value} %s %s';
                     $ex_msg = sprintf($ex_msg, gettype($value), $str_value);
                     throw new Cascade_Exception_DBException($ex_msg);
             }
             break;
         default:
             $str_value = Cascade_System_Util::export($value, TRUE);
             $ex_msg = 'Unexpected the type of bind-value {type, value} %d %d';
             $ex_msg = sprintf($ex_msg, $type, $str_value);
             throw new Cascade_Exception_DBException($ex_msg);
     }
     // 内部変数に保存
     $this->bind_values[] = $value;
     $this->bind_value_details[] = array(self::BIND_TYPE => $type, self::BIND_VAL => $value, self::BIND_ORIG_TYPE => $orig_type, self::BIND_ORIG_VAL => $orig);
 }