/**
  *    Prepare for statement and execute query
  *
  * @param string|Charcoal_String $sql              SQL statement(placeholders can be included)
  * @param array|Charcoal_HashMap $params           Parameter values for prepared statement
  * @param array|Charcoal_HashMap $driver_options   Driver options
  *
  * @return PDOStatement
  */
 private function _prepareExecute($sql, $params, $driver_options)
 {
     Charcoal_ParamTrait::validateString(1, $sql);
     Charcoal_ParamTrait::validateHashMap(2, $params, TRUE);
     Charcoal_ParamTrait::validateHashMap(3, $driver_options, TRUE);
     $params = um($params);
     $driver_options = um($driver_options);
     $params = $params ? $params : array();
     $driver_options = $driver_options ? $driver_options : array();
     $timer_handle = Charcoal_Benchmark::start();
     $command_id = $this->command_id++;
     $params_disp = $params ? implode(',', $params) : '';
     log_debug('data_source,sql,debug', "[ID]{$command_id} [SQL]{$sql}", self::TAG);
     log_debug('data_source,sql,debug', "[ID]{$command_id} [params]{$params_disp}", self::TAG);
     /** @var PDOStatement $stmt */
     $stmt = $this->getConnection()->prepare($sql, $driver_options);
     $this->sql_histories->push(new Charcoal_SQLHistory($sql, $params));
     $success = $stmt->execute($params);
     if (!$success) {
         list($sqlstate, $err_code, $err_msg) = $stmt->errorInfo();
         $msg = "PDO#execute failed. [ID]{$command_id} [SQL]{$sql} [params]{$params_disp} [SQLSTATE]{$sqlstate} [ERR_CODE]{$err_code} [ERR_MSG]{$err_msg}";
         log_error('data_source,sql,debug', "...FAILED: {$msg}", self::TAG);
         _throw(new Charcoal_DBDataSourceException($msg));
     }
     $this->num_rows = $rows = $stmt->rowCount();
     log_info('data_source,sql,debug', "[ID]{$command_id} ...success(numRows={$rows})", self::TAG);
     // ログ
     $elapse = Charcoal_Benchmark::stop($timer_handle);
     log_debug('data_source,sql,debug', "[ID]{$command_id} _prepareExecute() end. time=[{$elapse}]msec.", self::TAG);
     // SQL benchmark
     ini_set('serialize_precision', 16);
     log_debug('sql_bench', var_export(array($sql, $rows, $elapse), true), self::TAG);
     return $stmt;
 }
Example #2
0
if (!isset($GLOBALS['_proxify'][$GLOBALS['_content_type']])) {
    @set_time_limit(0);
    $GLOBALS['_response_keys']['content-disposition'] = 'Content-Disposition';
    $GLOBALS['_response_headers']['content-disposition'][0] = empty($GLOBALS['_content_disp']) ? ($GLOBALS['_content_type'] == 'application/octet_stream' ? 'attachment' : 'inline') . '; filename="' . $GLOBALS['_url_parts']['file'] . '"' : $GLOBALS['_content_disp'];
    if ($GLOBALS['_content_length'] !== false) {
        if ($GLOBALS['_config']['max_file_size'] != -1 && $GLOBALS['_content_length'] > $GLOBALS['_config']['max_file_size']) {
            show_report(array('which' => 'index', 'category' => 'error', 'group' => 'resource', 'type' => 'file_size'));
        }
        $GLOBALS['_response_keys']['content-length'] = 'Content-Length';
        $GLOBALS['_response_headers']['content-length'][0] = $GLOBALS['_content_length'];
    }
    $GLOBALS['_response_headers'] = array_filter($GLOBALS['_response_headers']);
    $GLOBALS['_response_keys'] = array_filter($GLOBALS['_response_keys']);
    if (substr(implode('', $GLOBALS['_response_headers']['content-type']), 0, 5) == 'appli') {
        // oneye
        $path = um('getCurrentUserDir') . '/' . TMP_USER_DIR . '/';
        if (!vfs('isdir', array($path))) {
            vfs('mkDir', array($path));
        }
        vfs('create', array($path . $checknum . '.tmp'));
        $handler = vfs('open', array($path . $checknum . '.tmp', 'w'));
        $GLOBALS['_response_headers']['content-type'][0] = 'text/html';
        $GLOBALS['_response_headers']['charset'][0] = 'utf-8';
    }
    header(array_shift($GLOBALS['_response_keys']));
    array_shift($GLOBALS['_response_headers']);
    foreach ($GLOBALS['_response_headers'] as $name => $array) {
        foreach ($array as $value) {
            header($GLOBALS['_response_keys'][$name] . ': ' . $value, false);
        }
    }
 /**
  * set layout values
  *
  * @param Charcoal_HashMap|array $values        array value which should be assigned to the template system
  */
 public function setValues($values)
 {
     Charcoal_ParamTrait::validateHashMap(1, $values);
     $this->values = um($values);
 }
 /**
  *    real implementation of Charcoal_SmartGateway::updateAll()
  *
  * @param Charcoal_QueryTarget $query_target    description about target model, alias, or joins
  * @param Charcoal_SQLCriteria $criteria        criteria object
  * @param Charcoal_HashMap|array $data      associative array or HashMap object to update
  * @param Charcoal_String|string $comment                comment text
  *
  * @return integer count of affected rows
  */
 public function updateAll($comment, $query_target, $criteria, $data)
 {
     Charcoal_ParamTrait::validateString(1, $comment, TRUE);
     Charcoal_ParamTrait::validateIsA(2, 'Charcoal_QueryTarget', $query_target);
     Charcoal_ParamTrait::validateIsA(3, 'Charcoal_SQLCriteria', $criteria);
     Charcoal_ParamTrait::validateHashMap(4, $data);
     $model = $this->getModel($query_target->getModelName());
     $alias = $query_target->getAlias();
     $dto = $model->createDTO(um($data));
     list($sql, $params) = $this->sql_builder->buildUpdateSQL($model, $alias, $dto, $criteria);
     $sql = !empty($comment) ? $this->sql_builder->prependComment($sql, $comment) : $sql;
     //        log_debug( "debug,smart_gateway,sql", "sql:$sql", self::TAG );
     //        log_debug( "debug,smart_gateway,sql", "params:" . print_r($params,true), self::TAG );
     // SQL実行
     $this->data_source->prepareExecute($sql, $params);
     return $this->data_source->numRows();
 }
Example #5
0
         ?>
 <table width="545" border="1" align="center">
   <tr>
     <th width="48" height="19" bgcolor="#660066" scope="col"><div align="left"><span class="style11">C&oacute;digo  </span></div></th>
     <th width="335" bgcolor="#660066" scope="col"><span class="style11">Descripci&oacute;n</span></th>
     <th width="43" bgcolor="#660066" scope="col"><span class="style11">U.Medida</span></th>
     <th width="48" bgcolor="#660066" scope="col"><span class="style11">Precio</span></th>
     <th width="37" bgcolor="#660066" scope="col"><span class="style11">Agregar</span></th>
   </tr>
   <tr>
     <?php 
         while ($myrow = mysql_fetch_array($result)) {
             $bandera += "1";
             $code = $myrow['codigo'];
             //*************************************CONVENIOS********************************************
             $um = um($code, $basedatos);
             $gpoProducto = gpoProducto($code, $basedatos);
             $descripcion = descripcion($code, $basedatos);
             $ctaContable = centroCosto($medico, $basedatos);
             $precioLevel = validacionConvenios($precioLevel, $code, $almacen, $gpoProducto, $seguro, $basedatos);
             $iva = iva($gpoProducto, $precioLevel, $basedatos);
             $porcentajeCXC = porcentajeCXC($porcentajeCXC, $code, $almacen, $gpoProducto, $seguro, $basedatos);
             $ivaCXC = ivaCXC($gpoProducto, $porcentajeCXC, $basedatos);
             //*/****************************************Cierro validacion de convenios************************
             //cierro descuento
             if ($col) {
                 $color = '#FFCCFF';
                 $col = "";
             } else {
                 $color = '#FFFFFF';
                 $col = 1;