当前位置: 首页>>代码示例>>PHP>>正文


PHP Helpers::get_type_size方法代码示例

本文整理汇总了PHP中Helpers::get_type_size方法的典型用法代码示例。如果您正苦于以下问题:PHP Helpers::get_type_size方法的具体用法?PHP Helpers::get_type_size怎么用?PHP Helpers::get_type_size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Helpers的用法示例。


在下文中一共展示了Helpers::get_type_size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTables

 /**
  * Parse values in map and add to corresponding table array.
  *
  * @return bool
  * @uses DatabaseMap::$map
  * @uses DatabaseMap::$table_separator
  * @uses DatabaseMap::$from_tables
  * @uses DatabaseMap::$to_tables
  */
 private function getTables()
 {
     $this->Log->write(__METHOD__, Log::LOG_LEVEL_SYSTEM_INFORMATION);
     // input validation
     if (empty($this->map)) {
         $this->Log->write('map is empty', Log::LOG_LEVEL_WARNING);
         return false;
     }
     $this->Log->write('looping through $this->map', Log::LOG_LEVEL_USER, $this->map);
     foreach ($this->map as $from => $to) {
         $this->Log->write('from', Log::LOG_LEVEL_USER, $from);
         $this->Log->write('to', Log::LOG_LEVEL_USER, $to);
         if ($to === 'skip') {
             $this->Log->write('skipping this one', Log::LOG_LEVEL_USER);
             continue;
         } elseif ($to === null || is_null($to) || !Helpers::is_string_ne($to)) {
             $this->Log->write('this is not a field to use', Log::LOG_LEVEL_WARNING, $from . ' => to ' . Helpers::get_type_size($to));
             continue;
         }
         list($from_table, $from_field) = explode($this->table_separator, $from);
         if (Helpers::is_string_ne($from_table)) {
             if (!array_key_exists($from_table, $this->from_tables)) {
                 $this->from_tables[$from_table] = array();
             }
             if (Helpers::is_string_ne($from_field) && !array_search($from_field, $this->from_tables[$from_table])) {
                 $this->from_tables[$from_table][] = $from_field;
             }
         }
         // populate is a value that is used to indicate the value is needed, but the field is not needed
         if ($to !== 'populate' && strstr($to, $this->table_separator)) {
             list($to_table, $to_field) = explode($this->table_separator, $to);
             if (Helpers::is_string_ne($to_table)) {
                 if (!array_key_exists($to_table, $this->to_tables)) {
                     $this->to_tables[$to_table] = array();
                 }
                 if (Helpers::is_string_ne($to_field) && !array_search($to_field, $this->to_tables[$to_table])) {
                     $this->to_tables[$to_table][] = $to_field;
                 }
             }
         }
     }
     $this->Log->write('finished looping through $this->map', Log::LOG_LEVEL_USER);
     return true;
 }
开发者ID:mts7,项目名称:mtsapps-framework,代码行数:53,代码来源:DatabaseMap.php

示例2: importFile

 /**
  * Import a file to MySQL through command line.
  *
  * @param string $file
  * @return bool
  * @todo Make this available for other SQL variants.
  */
 public function importFile($file = '')
 {
     $this->Log->write(__METHOD__, Log::LOG_LEVEL_SYSTEM_INFORMATION);
     // input validation
     if (!Helpers::is_string_ne($file)) {
         $this->Log->write('no file provided', Log::LOG_LEVEL_WARNING, Helpers::get_type_size($file));
         return false;
     }
     if (!is_file($file)) {
         $this->Log->write('file does not exist', Log::LOG_LEVEL_WARNING, $file);
         return false;
     }
     $ext = substr($file, -3);
     if (strtolower($ext) !== 'sql') {
         $this->Log->write('file extension must be sql', Log::LOG_LEVEL_WARNING, $ext);
         return false;
     }
     $command = MYSQL_BIN . 'mysql --verbose -h ' . $this->host . ' -u' . $this->user;
     if (Helpers::is_string_ne($this->pass)) {
         $command .= ' -p\'' . trim($this->pass) . '\'';
     }
     $command .= ' ' . $this->dbname . ' < ' . $file;
     $output = array();
     exec($command, $output, $return_var);
     if ($return_var != 0) {
         $this->Log->write($return_var . ': Failed to import from file', Log::LOG_LEVEL_WARNING, $output);
         return false;
     }
     return true;
 }
开发者ID:mts7,项目名称:mtsapps-framework,代码行数:37,代码来源:Db.php

示例3: generate

 /**
  * Generate PHP string for this table and field.
  *
  * @param array $array Row of results from constant list
  * @return bool|int
  * @uses Db::query()
  * @uses Db::quote()
  */
 protected function generate($array = array())
 {
     $this->Log->write(__METHOD__, Log::LOG_LEVEL_SYSTEM_INFORMATION);
     // input validation
     if (!Helpers::is_array_ne($array)) {
         $this->Log->write('array is invalid', Log::LOG_LEVEL_WARNING, Helpers::get_call_string());
         return false;
     }
     // these fields need to be present in the array
     $fields = array('table_name', 'name_field', 'value_field', 'type');
     $valid = true;
     // check for the existence of each field in the array and break if one of them does not exist
     foreach ($fields as $field) {
         if (!array_key_exists($field, $array)) {
             $valid = false;
             break;
         }
     }
     if (!$valid) {
         $this->Log->write('input invalid', Log::LOG_LEVEL_WARNING);
         return false;
     }
     // assign parameters to variables
     $table = $array['table_name'];
     $field = $array['name_field'];
     $value_field = $array['value_field'];
     $type = $array['type'];
     $prefix = array_key_exists('prefix', $array) ? $array['prefix'] : $table;
     // build SELECT query for field and value
     $sql = 'SELECT ' . $field . ', ' . $value_field . PHP_EOL;
     $sql .= '  FROM ' . $table . PHP_EOL;
     $this->Log->write('generate SQL', Log::LOG_LEVEL_USER, $sql);
     // get rows from table
     $rows = $this->query($sql, array(), 'iterator');
     if (!$rows instanceof DbIterator) {
         $this->Log->write('could not find rows from query', Log::LOG_LEVEL_WARNING);
         return false;
     }
     $this->Log->write('found rows for generate query', Log::LOG_LEVEL_USER);
     // build PHP string with comments to indicate table and field used in generation
     $php = PHP_EOL . '/**' . PHP_EOL;
     $php .= ' * ' . $table . '.' . $field . PHP_EOL;
     $php .= ' */' . PHP_EOL;
     foreach ($rows as $row) {
         if ($row === null || !array_key_exists($field, $row)) {
             continue;
         }
         // prepare constant name (upper case, underscores instead of spaces, no multiple underscores together)
         $val = strtoupper(Helpers::space_to_underscore($prefix . '_' . $row[$field]));
         // add define statement to string
         $php .= 'define(\'' . $val . '\', ' . $this->quote($row[$value_field], $type) . ');' . PHP_EOL;
     }
     $php .= '// END ' . $table . '.' . $field . PHP_EOL . PHP_EOL;
     $this->Log->write('built PHP string with ' . strlen($php) . ' characters', Log::LOG_LEVEL_USER);
     if (!Helpers::is_string_ne($php)) {
         $this->Log->write('There was an issue building the PHP.', Log::LOG_LEVEL_WARNING, Helpers::get_type_size($php));
         return false;
     }
     // append string to global string
     $this->php .= $php;
     return strlen($php);
 }
开发者ID:mts7,项目名称:mtsapps-framework,代码行数:70,代码来源:Constants.php


注:本文中的Helpers::get_type_size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。