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


PHP mysqli_num_fields函数代码示例

本文整理汇总了PHP中mysqli_num_fields函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_num_fields函数的具体用法?PHP mysqli_num_fields怎么用?PHP mysqli_num_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: iimysqli_stmt_get_result

 public static function iimysqli_stmt_get_result($stmt)
 {
     /**    EXPLANATION:
      * We are creating a fake "result" structure to enable us to have
      * source-level equivalent syntax to a query executed via
      * mysqli_query().
      *
      *    $stmt = mysqli_prepare($conn, "");
      *    mysqli_bind_param($stmt, "types", ...);
      *
      *    $param1 = 0;
      *    $param2 = 'foo';
      *    $param3 = 'bar';
      *    mysqli_execute($stmt);
      *    $result _mysqli_stmt_get_result($stmt);
      *        [ $arr = _mysqli_result_fetch_array($result);
      *            || $assoc = _mysqli_result_fetch_assoc($result); ]
      *    mysqli_stmt_close($stmt);
      *    mysqli_close($conn);
      *
      * At the source level, there is no difference between this and mysqlnd.
      **/
     $metadata = mysqli_stmt_result_metadata($stmt);
     $ret = new iimysqli_result();
     if (!$ret) {
         return NULL;
     }
     $ret->nCols = mysqli_num_fields($metadata);
     $ret->columns = $metadata->fetch_fields();
     $ret->stmt = $stmt;
     mysqli_free_result($metadata);
     return $ret;
 }
开发者ID:senioroman4uk,项目名称:Simple-PHP-MVC,代码行数:33,代码来源:iimysqli_result.php

示例2: query

 /**
  * @param string $query
  * @param int $singleResult
  * @return array
  */
 function query($query, $singleResult = 0)
 {
     $this->_result = mysqli_query($this->_dbHandle, $query);
     if (preg_match("/select/i", $query)) {
         $result = array();
         $table = array();
         $field = array();
         $tempResults = array();
         $numOfFields = mysqli_num_fields($this->_result);
         while ($fdata = mysqli_fetch__field($this->_result)) {
             array_push($table, $fdata->table);
             array_push($field, $fdata->name);
         }
         while ($row = mysqli_fetch_row($this->_result)) {
             for ($i = 0; $i < $numOfFields; ++$i) {
                 $table[$i] = trim(ucfirst($table[$i]), 's');
                 $tempResults[$table[$i]][$field[$i]] = $row[$i];
             }
             if ($singleResult == 1) {
                 mysqli_free_result($this->_result);
                 return $tempResults;
             }
             array_push($result, $tempResults);
         }
         mysqli_free_result($this->_result);
         return $result;
     }
 }
开发者ID:mnpollotta,项目名称:webinar-framework,代码行数:33,代码来源:Query.php

示例3: single_edit

function single_edit($tbl, $col, $id)
{
    $result = getSingle($tbl, $col, $id);
    $getResult = mysqli_fetch_array($result);
    echo "<form action=\"edit.php\" method=\"POST\">";
    echo "<input type=\"hidden\" name=\"tbl\" value=\"{$tbl}\">";
    echo "<input type=\"hidden\" name=\"col\" value=\"{$col}\">";
    echo "<input type=\"hidden\" name=\"id\" value=\"{$id}\">";
    for ($i = 0; $i < mysqli_num_fields($result); $i++) {
        $dataType = mysqli_fetch_field_direct($result, $i);
        //expects two arguments
        $fieldName = $dataType->name;
        //like an associative array - allows you to dig into the object and look for "name" (seen as the label in the object with the ->)
        //$title = explode('_', $fieldName);
        $fieldType = $dataType->type;
        //returns a number that can be used
        if ($fieldName != $col) {
            echo "<label>{$fieldName}</label><br>";
            if ($fieldType != 252) {
                echo "<input type=\"text\" name=\"{$fieldName}\" value=\"{$getResult[$i]}\">";
            } else {
                echo "<textarea name=\"{$fieldName}\">{$getResult[$i]}</textarea>";
            }
        }
    }
    echo "<input type=\"submit\" value=\"Save Content\">";
    echo "</form>";
}
开发者ID:jocchann,项目名称:edfc,代码行数:28,代码来源:single_edit_form.php

示例4: __get

 /**
  * Dynamic Get Function Override
  *
  * @param $name
  *   A string containing the name of the property to get.
  * @return
  *   Value of the property.
  */
 public function __get($propertyName)
 {
     global $firePHP;
     if ($propertyName == 'columns') {
         if (!isset($this->_columns)) {
             //---- Get Columns
             $this->_columns = new anvilCollection();
             $i = 0;
             $numFields = mysqli_num_fields($this->result);
             while ($i < $numFields) {
                 //				   $meta = mysqli_fetch_field($this->result, $i);
                 $meta = mysqli_fetch_field($this->result);
                 if ($meta) {
                     //						$this->_columns->add(new anvilData_mysqli_Column($meta->name, $meta->type));
                     $firePHP->_log($meta);
                     $newColumn = new anvilData_mysqli_Column($meta->name, $meta->type);
                     $this->_columns->add($newColumn);
                 }
                 $i++;
             }
         }
         return $this->_columns;
     } else {
         return parent::__get($propertyName);
     }
 }
开发者ID:nslevkoff,项目名称:phpAnvil2,代码行数:34,代码来源:anvilData_mysqli_Recordset.class.php

示例5: old_mysql_result

/**
 * Fonction basée sur l'api mysqli et
 * simulant la fonction mysql_result()
 * Copyright 2014 Marc Leygnac
 *
 * @param type $result résultat après requête
 * @param integer $row numéro de la ligne
 * @param string/integer $field indice ou nom du champ
 * @return type valeur du champ ou false si erreur
 */
function old_mysql_result($result, $row, $field = 0)
{
    if ($result === false) {
        return false;
    }
    if ($row >= mysqli_num_rows($result)) {
        return false;
    }
    if (is_string($field) && !(strpos($field, ".") === false)) {
        // si $field est de la forme table.field ou alias.field
        // on convertit $field en indice numérique
        $t_field = explode(".", $field);
        $field = -1;
        $t_fields = mysqli_fetch_fields($result);
        for ($id = 0; $id < mysqli_num_fields($result); $id++) {
            if ($t_fields[$id]->table == $t_field[0] && $t_fields[$id]->name == $t_field[1]) {
                $field = $id;
                break;
            }
        }
        if ($field == -1) {
            return false;
        }
    }
    mysqli_data_seek($result, $row);
    $line = mysqli_fetch_array($result);
    return isset($line[$field]) ? $line[$field] : false;
}
开发者ID:rhertzog,项目名称:lcs,代码行数:38,代码来源:old_mysql_result.php

示例6: query

 /** Custom SQL Query **/
 function query($query, $singleResult = 0)
 {
     //$query = mysqli_real_escape_string($this->_dbHandle,$query);
     //var_dump($query);
     $this->_result = mysqli_query($this->_dbHandle, $query);
     if (preg_match("/select/i", $query)) {
         $result = array();
         $table = array();
         $field = array();
         $tempResults = array();
         $numOfFields = mysqli_num_fields($this->_result);
         for ($i = 0; $i < $numOfFields; ++$i) {
             $table_name = mysqli_fetch_field_direct($this->_result, $i);
             array_push($table, $table_name->table);
             $fld = mysqli_fetch_field_direct($this->_result, $i);
             array_push($field, $fld->name);
         }
         while ($row = mysqli_fetch_row($this->_result)) {
             for ($i = 0; $i < $numOfFields; ++$i) {
                 $table[$i] = trim(ucfirst($table[$i]), "s");
                 $tempResults[$table[$i]][$field[$i]] = $row[$i];
             }
             if ($singleResult == 1) {
                 mysqli_free_result($this->_result);
                 return $tempResults;
             }
             array_push($result, $tempResults);
         }
         mysqli_free_result($this->_result);
         return $result;
     }
 }
开发者ID:mr-madjarov,项目名称:students-manager,代码行数:33,代码来源:sqlquery.class.php

示例7: getNumFields

 public function getNumFields()
 {
     if ($this->usemysqli) {
         return mysqli_num_fields($this->result);
     } else {
         return mysql_numfields($this->result);
     }
 }
开发者ID:BackupTheBerlios,项目名称:alien-svn,代码行数:8,代码来源:result.php

示例8: num_fields

 function num_fields($res)
 {
     if ($num = mysqli_num_fields($res)) {
         return $num;
     } else {
         return false;
     }
 }
开发者ID:ricardoletelier,项目名称:conexion-mysqli-postgresql-desde-php,代码行数:8,代码来源:mysqli.php

示例9: write_data_mysqli

 /**
  * Extracts data from database table (for MySQLi driver)
  *
  * @param	string	$table_name	name of the database table
  * @return null
  * @throws \phpbb\db\extractor\exception\extractor_not_initialized_exception when calling this function before init_extractor()
  */
 protected function write_data_mysqli($table_name)
 {
     if (!$this->is_initialized) {
         throw new extractor_not_initialized_exception();
     }
     $sql = "SELECT *\n\t\t\tFROM {$table_name}";
     $result = mysqli_query($this->db->get_db_connect_id(), $sql, MYSQLI_USE_RESULT);
     if ($result != false) {
         $fields_cnt = mysqli_num_fields($result);
         // Get field information
         $field = mysqli_fetch_fields($result);
         $field_set = array();
         for ($j = 0; $j < $fields_cnt; $j++) {
             $field_set[] = $field[$j]->name;
         }
         $search = array("\\", "'", "", "\n", "\r", "", '"');
         $replace = array("\\\\", "\\'", '\\0', '\\n', '\\r', '\\Z', '\\"');
         $fields = implode(', ', $field_set);
         $sql_data = 'INSERT INTO ' . $table_name . ' (' . $fields . ') VALUES ';
         $first_set = true;
         $query_len = 0;
         $max_len = get_usable_memory();
         while ($row = mysqli_fetch_row($result)) {
             $values = array();
             if ($first_set) {
                 $query = $sql_data . '(';
             } else {
                 $query .= ',(';
             }
             for ($j = 0; $j < $fields_cnt; $j++) {
                 if (!isset($row[$j]) || is_null($row[$j])) {
                     $values[$j] = 'NULL';
                 } else {
                     if ($field[$j]->flags & 32768 && !($field[$j]->flags & 1024)) {
                         $values[$j] = $row[$j];
                     } else {
                         $values[$j] = "'" . str_replace($search, $replace, $row[$j]) . "'";
                     }
                 }
             }
             $query .= implode(', ', $values) . ')';
             $query_len += strlen($query);
             if ($query_len > $max_len) {
                 $this->flush($query . ";\n\n");
                 $query = '';
                 $query_len = 0;
                 $first_set = true;
             } else {
                 $first_set = false;
             }
         }
         mysqli_free_result($result);
         // check to make sure we have nothing left to flush
         if (!$first_set && $query) {
             $this->flush($query . ";\n\n");
         }
     }
 }
开发者ID:MrAdder,项目名称:phpbb,代码行数:65,代码来源:mysql_extractor.php

示例10: db_num_fields

function db_num_fields($res)
{
    switch (DATABASE) {
        case 'mysql':
            return mysql_num_fields($res);
        case 'mysqli':
            return mysqli_num_fields($res);
    }
}
开发者ID:vishwanathhsinhaa,项目名称:tieuthuong-org,代码行数:9,代码来源:db.php

示例11: _getFieldCount

 function _getFieldCount()
 {
     if (is_object($this->_cursor) && get_class($this->_cursor) == "mysqli_result") {
         $fields = mysqli_num_fields($this->_cursor);
         return $fields;
     }
     // This is either a broken db connection or a bad query
     return 0;
 }
开发者ID:RangerWalt,项目名称:ecci,代码行数:9,代码来源:intercept.jdatabasemysqli.php

示例12: backup

 public static function backup($tables = '*')
 {
     ini_set('memory_limit', '2048M');
     set_time_limit(0);
     $folder = dirname(__FILE__) . "/../backup";
     $file = 'backup' . date("Ymd");
     if (!file_exists("{$folder}/{$file}")) {
         echo "creando {$folder}/{$file}";
         $old_mask = umask(0);
         mkdir("{$folder}/{$file}", 0757);
         umask($old_mask);
     }
     if ($tables == '*') {
         $tables = array();
         $result = self::consultar('SHOW TABLES FROM Proyecto');
         while ($row = mysqli_fetch_row($result)) {
             $tables[] = $row[0];
         }
     } else {
         $tables = is_array($tables) ? $tables : explode(',', $tables);
     }
     foreach ($tables as $table) {
         $return = '';
         $result = self::consultar('SELECT * FROM ' . $table);
         $num_fields = mysqli_num_fields($result);
         $row2 = mysqli_fetch_row(self::consultar('SHOW CREATE TABLE ' . $table));
         $return .= "\n\n" . $row2[1] . ";\n\n";
         for ($i = 0; $i < $num_fields; $i++) {
             while ($row = mysqli_fetch_row($result)) {
                 $return .= 'INSERT INTO ' . $table . ' VALUES(';
                 for ($j = 0; $j < $num_fields; $j++) {
                     $row[$j] = addslashes($row[$j]);
                     $row[$j] = preg_replace("/\n/", "\\n", $row[$j]);
                     if (isset($row[$j])) {
                         $return .= '"' . $row[$j] . '"';
                     } else {
                         $return .= '""';
                     }
                     if ($j < $num_fields - 1) {
                         $return .= ',';
                     }
                 }
                 $return .= ");\n";
             }
         }
         $return .= "\n\n\n";
         //save file
         $handle = fopen("{$folder}/{$file}/{$table}.sql", 'w+');
         if (fwrite($handle, $return)) {
             echo "Tabla: {$table} guardada correctamente en {$folder}/{$table}.sql.";
         } else {
             echo "No se pudo hacer la copia para la tabla {$table}";
         }
     }
     fclose($handle);
     return $file;
 }
开发者ID:jalvjim,项目名称:AWeb,代码行数:57,代码来源:BD.class.php

示例13: mysqliAdapter

 /**
  * Constructor method for the adapter.  This constructor implements the setting of the
  * 3 required properties for the object.
  * 
  * @param resource $d The datasource resource
  */
 function mysqliAdapter($d)
 {
     parent::RecordSetAdapter($d);
     $fieldcount = mysqli_num_fields($d);
     $ob = "";
     $be = $this->isBigEndian;
     $fc = pack('N', $fieldcount);
     if (mysqli_num_rows($d) > 0) {
         mysqli_data_seek($d, 0);
         while ($line = mysqli_fetch_row($d)) {
             // write all of the array elements
             $ob .= "\n" . $fc;
             foreach ($line as $value) {
                 // write all of the array elements
                 if (is_string($value)) {
                     // type as string
                     $os = $this->_directCharsetHandler->transliterate($value);
                     //string flag, string length, and string
                     $len = strlen($os);
                     if ($len < 65536) {
                         $ob .= "" . pack('n', $len) . $os;
                     } else {
                         $ob .= "\f" . pack('N', $len) . $os;
                     }
                 } elseif (is_float($value) || is_int($value)) {
                     // type as double
                     $b = pack('d', $value);
                     // pack the bytes
                     if ($be) {
                         // if we are a big-endian processor
                         $r = strrev($b);
                     } else {
                         // add the bytes to the output
                         $r = $b;
                     }
                     $ob .= "" . $r;
                 } elseif (is_bool($value)) {
                     //type as bool
                     $ob .= "";
                     $ob .= pack('c', $value);
                 } elseif (is_null($value)) {
                     // null
                     $ob .= "";
                 }
             }
         }
     }
     $this->serializedData = $ob;
     // loop over all of the fields
     while ($field = mysqli_fetch_field($d)) {
         // decode each field name ready for encoding when it goes through serialization
         // and save each field name into the array
         $this->columnNames[] = $this->_directCharsetHandler->transliterate($field->name);
     }
     $this->numRows = mysqli_num_rows($d);
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:62,代码来源:mysqliAdapter.php

示例14: dumpMySQL

function dumpMySQL()
{
    global $dbc;
    $connexion = $dbc;
    $entete = "-- ----------------------\n";
    $entete .= "-- dump de la base " . $base . " au " . date("d-M-Y") . "\n";
    $entete .= "-- ----------------------\n\n\n";
    $creations = "";
    $insertions = "\n\n";
    $listeTables = mysqli_query($connexion, "show tables");
    while ($table = mysqli_fetch_array($listeTables)) {
        // si l'utilisateur a demande la structure ou la totale
        //if ( $table[0] == "cahiertxt" || $table[0] == "onglets" )
        if (mb_ereg("^cahiertxt", $table[0]) || mb_ereg("^onglets", $table[0])) {
            $creations .= "-- -----------------------------\n";
            $creations .= "-- creation de la table " . $table[0] . "\n";
            $creations .= "-- -----------------------------\n";
            $creations .= "DROP TABLE IF EXISTS `" . $table[0] . "`;\n";
            $listeCreationsTables = mysqli_query($connexion, "show create table " . $table[0]);
            while ($creationTable = mysqli_fetch_array($listeCreationsTables)) {
                $creations .= $creationTable[1] . ";\n\n";
            }
            //donnees
            $donnees = mysqli_query($GLOBALS["___mysqli_ston"], "SELECT * FROM " . $table[0] . "  WHERE login='" . $_SESSION['login'] . "'");
            $insertions .= "-- -----------------------------\n";
            $insertions .= "-- insertions dans la table " . $table[0] . "\n";
            $insertions .= "-- -----------------------------\n";
            while ($nuplet = mysqli_fetch_array($donnees)) {
                $insertions .= "INSERT INTO " . $table[0] . " VALUES(";
                for ($i = 0; $i < (($___mysqli_tmp = mysqli_num_fields($donnees)) ? $___mysqli_tmp : false); $i++) {
                    if ($i != 0) {
                        $insertions .= ", ";
                    }
                    if ((is_object($___mysqli_tmp = mysqli_fetch_field_direct($donnees, 0)) && !is_null($___mysqli_tmp = $___mysqli_tmp->type) ? ($___mysqli_tmp = (string) substr(($___mysqli_tmp == MYSQLI_TYPE_STRING || $___mysqli_tmp == MYSQLI_TYPE_VAR_STRING ? "string " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_LONG, MYSQLI_TYPE_LONGLONG, MYSQLI_TYPE_INT24)) ? "int " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_FLOAT, MYSQLI_TYPE_DOUBLE, MYSQLI_TYPE_DECIMAL, defined("MYSQLI_TYPE_NEWDECIMAL") ? constant("MYSQLI_TYPE_NEWDECIMAL") : -1)) ? "real " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIMESTAMP ? "timestamp " : "") . ($___mysqli_tmp == MYSQLI_TYPE_YEAR ? "year " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATE || $___mysqli_tmp == MYSQLI_TYPE_NEWDATE ? "date " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIME ? "time " : "") . ($___mysqli_tmp == MYSQLI_TYPE_SET ? "set " : "") . ($___mysqli_tmp == MYSQLI_TYPE_ENUM ? "enum " : "") . ($___mysqli_tmp == MYSQLI_TYPE_GEOMETRY ? "geometry " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATETIME ? "datetime " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY_BLOB, MYSQLI_TYPE_BLOB, MYSQLI_TYPE_MEDIUM_BLOB, MYSQLI_TYPE_LONG_BLOB)) ? "blob " : "") . ($___mysqli_tmp == MYSQLI_TYPE_NULL ? "null " : ""), 0, -1)) == "" ? "unknown" : $___mysqli_tmp : false) == "string" || (is_object($___mysqli_tmp = mysqli_fetch_field_direct($donnees, 0)) && !is_null($___mysqli_tmp = $___mysqli_tmp->type) ? ($___mysqli_tmp = (string) substr(($___mysqli_tmp == MYSQLI_TYPE_STRING || $___mysqli_tmp == MYSQLI_TYPE_VAR_STRING ? "string " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_LONG, MYSQLI_TYPE_LONGLONG, MYSQLI_TYPE_INT24)) ? "int " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_FLOAT, MYSQLI_TYPE_DOUBLE, MYSQLI_TYPE_DECIMAL, defined("MYSQLI_TYPE_NEWDECIMAL") ? constant("MYSQLI_TYPE_NEWDECIMAL") : -1)) ? "real " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIMESTAMP ? "timestamp " : "") . ($___mysqli_tmp == MYSQLI_TYPE_YEAR ? "year " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATE || $___mysqli_tmp == MYSQLI_TYPE_NEWDATE ? "date " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIME ? "time " : "") . ($___mysqli_tmp == MYSQLI_TYPE_SET ? "set " : "") . ($___mysqli_tmp == MYSQLI_TYPE_ENUM ? "enum " : "") . ($___mysqli_tmp == MYSQLI_TYPE_GEOMETRY ? "geometry " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATETIME ? "datetime " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY_BLOB, MYSQLI_TYPE_BLOB, MYSQLI_TYPE_MEDIUM_BLOB, MYSQLI_TYPE_LONG_BLOB)) ? "blob " : "") . ($___mysqli_tmp == MYSQLI_TYPE_NULL ? "null " : ""), 0, -1)) == "" ? "unknown" : $___mysqli_tmp : false) == "blob" || (is_object($___mysqli_tmp = mysqli_fetch_field_direct($donnees, 0)) && !is_null($___mysqli_tmp = $___mysqli_tmp->type) ? ($___mysqli_tmp = (string) substr(($___mysqli_tmp == MYSQLI_TYPE_STRING || $___mysqli_tmp == MYSQLI_TYPE_VAR_STRING ? "string " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_LONG, MYSQLI_TYPE_LONGLONG, MYSQLI_TYPE_INT24)) ? "int " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_FLOAT, MYSQLI_TYPE_DOUBLE, MYSQLI_TYPE_DECIMAL, defined("MYSQLI_TYPE_NEWDECIMAL") ? constant("MYSQLI_TYPE_NEWDECIMAL") : -1)) ? "real " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIMESTAMP ? "timestamp " : "") . ($___mysqli_tmp == MYSQLI_TYPE_YEAR ? "year " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATE || $___mysqli_tmp == MYSQLI_TYPE_NEWDATE ? "date " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIME ? "time " : "") . ($___mysqli_tmp == MYSQLI_TYPE_SET ? "set " : "") . ($___mysqli_tmp == MYSQLI_TYPE_ENUM ? "enum " : "") . ($___mysqli_tmp == MYSQLI_TYPE_GEOMETRY ? "geometry " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATETIME ? "datetime " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY_BLOB, MYSQLI_TYPE_BLOB, MYSQLI_TYPE_MEDIUM_BLOB, MYSQLI_TYPE_LONG_BLOB)) ? "blob " : "") . ($___mysqli_tmp == MYSQLI_TYPE_NULL ? "null " : ""), 0, -1)) == "" ? "unknown" : $___mysqli_tmp : false) == "timestamp" || (is_object($___mysqli_tmp = mysqli_fetch_field_direct($donnees, 0)) && !is_null($___mysqli_tmp = $___mysqli_tmp->type) ? ($___mysqli_tmp = (string) substr(($___mysqli_tmp == MYSQLI_TYPE_STRING || $___mysqli_tmp == MYSQLI_TYPE_VAR_STRING ? "string " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_LONG, MYSQLI_TYPE_LONGLONG, MYSQLI_TYPE_INT24)) ? "int " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_FLOAT, MYSQLI_TYPE_DOUBLE, MYSQLI_TYPE_DECIMAL, defined("MYSQLI_TYPE_NEWDECIMAL") ? constant("MYSQLI_TYPE_NEWDECIMAL") : -1)) ? "real " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIMESTAMP ? "timestamp " : "") . ($___mysqli_tmp == MYSQLI_TYPE_YEAR ? "year " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATE || $___mysqli_tmp == MYSQLI_TYPE_NEWDATE ? "date " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIME ? "time " : "") . ($___mysqli_tmp == MYSQLI_TYPE_SET ? "set " : "") . ($___mysqli_tmp == MYSQLI_TYPE_ENUM ? "enum " : "") . ($___mysqli_tmp == MYSQLI_TYPE_GEOMETRY ? "geometry " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATETIME ? "datetime " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY_BLOB, MYSQLI_TYPE_BLOB, MYSQLI_TYPE_MEDIUM_BLOB, MYSQLI_TYPE_LONG_BLOB)) ? "blob " : "") . ($___mysqli_tmp == MYSQLI_TYPE_NULL ? "null " : ""), 0, -1)) == "" ? "unknown" : $___mysqli_tmp : false) == "date") {
                        $insertions .= "'";
                    }
                    $insertions .= addslashes($nuplet[$i]);
                    if ((is_object($___mysqli_tmp = mysqli_fetch_field_direct($donnees, 0)) && !is_null($___mysqli_tmp = $___mysqli_tmp->type) ? ($___mysqli_tmp = (string) substr(($___mysqli_tmp == MYSQLI_TYPE_STRING || $___mysqli_tmp == MYSQLI_TYPE_VAR_STRING ? "string " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_LONG, MYSQLI_TYPE_LONGLONG, MYSQLI_TYPE_INT24)) ? "int " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_FLOAT, MYSQLI_TYPE_DOUBLE, MYSQLI_TYPE_DECIMAL, defined("MYSQLI_TYPE_NEWDECIMAL") ? constant("MYSQLI_TYPE_NEWDECIMAL") : -1)) ? "real " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIMESTAMP ? "timestamp " : "") . ($___mysqli_tmp == MYSQLI_TYPE_YEAR ? "year " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATE || $___mysqli_tmp == MYSQLI_TYPE_NEWDATE ? "date " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIME ? "time " : "") . ($___mysqli_tmp == MYSQLI_TYPE_SET ? "set " : "") . ($___mysqli_tmp == MYSQLI_TYPE_ENUM ? "enum " : "") . ($___mysqli_tmp == MYSQLI_TYPE_GEOMETRY ? "geometry " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATETIME ? "datetime " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY_BLOB, MYSQLI_TYPE_BLOB, MYSQLI_TYPE_MEDIUM_BLOB, MYSQLI_TYPE_LONG_BLOB)) ? "blob " : "") . ($___mysqli_tmp == MYSQLI_TYPE_NULL ? "null " : ""), 0, -1)) == "" ? "unknown" : $___mysqli_tmp : false) == "string" || (is_object($___mysqli_tmp = mysqli_fetch_field_direct($donnees, 0)) && !is_null($___mysqli_tmp = $___mysqli_tmp->type) ? ($___mysqli_tmp = (string) substr(($___mysqli_tmp == MYSQLI_TYPE_STRING || $___mysqli_tmp == MYSQLI_TYPE_VAR_STRING ? "string " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_LONG, MYSQLI_TYPE_LONGLONG, MYSQLI_TYPE_INT24)) ? "int " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_FLOAT, MYSQLI_TYPE_DOUBLE, MYSQLI_TYPE_DECIMAL, defined("MYSQLI_TYPE_NEWDECIMAL") ? constant("MYSQLI_TYPE_NEWDECIMAL") : -1)) ? "real " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIMESTAMP ? "timestamp " : "") . ($___mysqli_tmp == MYSQLI_TYPE_YEAR ? "year " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATE || $___mysqli_tmp == MYSQLI_TYPE_NEWDATE ? "date " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIME ? "time " : "") . ($___mysqli_tmp == MYSQLI_TYPE_SET ? "set " : "") . ($___mysqli_tmp == MYSQLI_TYPE_ENUM ? "enum " : "") . ($___mysqli_tmp == MYSQLI_TYPE_GEOMETRY ? "geometry " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATETIME ? "datetime " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY_BLOB, MYSQLI_TYPE_BLOB, MYSQLI_TYPE_MEDIUM_BLOB, MYSQLI_TYPE_LONG_BLOB)) ? "blob " : "") . ($___mysqli_tmp == MYSQLI_TYPE_NULL ? "null " : ""), 0, -1)) == "" ? "unknown" : $___mysqli_tmp : false) == "blob" || (is_object($___mysqli_tmp = mysqli_fetch_field_direct($donnees, 0)) && !is_null($___mysqli_tmp = $___mysqli_tmp->type) ? ($___mysqli_tmp = (string) substr(($___mysqli_tmp == MYSQLI_TYPE_STRING || $___mysqli_tmp == MYSQLI_TYPE_VAR_STRING ? "string " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_LONG, MYSQLI_TYPE_LONGLONG, MYSQLI_TYPE_INT24)) ? "int " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_FLOAT, MYSQLI_TYPE_DOUBLE, MYSQLI_TYPE_DECIMAL, defined("MYSQLI_TYPE_NEWDECIMAL") ? constant("MYSQLI_TYPE_NEWDECIMAL") : -1)) ? "real " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIMESTAMP ? "timestamp " : "") . ($___mysqli_tmp == MYSQLI_TYPE_YEAR ? "year " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATE || $___mysqli_tmp == MYSQLI_TYPE_NEWDATE ? "date " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIME ? "time " : "") . ($___mysqli_tmp == MYSQLI_TYPE_SET ? "set " : "") . ($___mysqli_tmp == MYSQLI_TYPE_ENUM ? "enum " : "") . ($___mysqli_tmp == MYSQLI_TYPE_GEOMETRY ? "geometry " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATETIME ? "datetime " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY_BLOB, MYSQLI_TYPE_BLOB, MYSQLI_TYPE_MEDIUM_BLOB, MYSQLI_TYPE_LONG_BLOB)) ? "blob " : "") . ($___mysqli_tmp == MYSQLI_TYPE_NULL ? "null " : ""), 0, -1)) == "" ? "unknown" : $___mysqli_tmp : false) == "timestamp" || (is_object($___mysqli_tmp = mysqli_fetch_field_direct($donnees, 0)) && !is_null($___mysqli_tmp = $___mysqli_tmp->type) ? ($___mysqli_tmp = (string) substr(($___mysqli_tmp == MYSQLI_TYPE_STRING || $___mysqli_tmp == MYSQLI_TYPE_VAR_STRING ? "string " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY, MYSQLI_TYPE_SHORT, MYSQLI_TYPE_LONG, MYSQLI_TYPE_LONGLONG, MYSQLI_TYPE_INT24)) ? "int " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_FLOAT, MYSQLI_TYPE_DOUBLE, MYSQLI_TYPE_DECIMAL, defined("MYSQLI_TYPE_NEWDECIMAL") ? constant("MYSQLI_TYPE_NEWDECIMAL") : -1)) ? "real " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIMESTAMP ? "timestamp " : "") . ($___mysqli_tmp == MYSQLI_TYPE_YEAR ? "year " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATE || $___mysqli_tmp == MYSQLI_TYPE_NEWDATE ? "date " : "") . ($___mysqli_tmp == MYSQLI_TYPE_TIME ? "time " : "") . ($___mysqli_tmp == MYSQLI_TYPE_SET ? "set " : "") . ($___mysqli_tmp == MYSQLI_TYPE_ENUM ? "enum " : "") . ($___mysqli_tmp == MYSQLI_TYPE_GEOMETRY ? "geometry " : "") . ($___mysqli_tmp == MYSQLI_TYPE_DATETIME ? "datetime " : "") . (in_array($___mysqli_tmp, array(MYSQLI_TYPE_TINY_BLOB, MYSQLI_TYPE_BLOB, MYSQLI_TYPE_MEDIUM_BLOB, MYSQLI_TYPE_LONG_BLOB)) ? "blob " : "") . ($___mysqli_tmp == MYSQLI_TYPE_NULL ? "null " : ""), 0, -1)) == "" ? "unknown" : $___mysqli_tmp : false) == "date") {
                        $insertions .= "'";
                    }
                }
                $insertions .= ");\n";
            }
            $insertions .= "\n";
        }
    }
    is_null($___mysqli_res = mysqli_close($connexion)) ? false : $___mysqli_res;
    $rep_tmp = "/tmp/" . $_SESSION['login'];
    mkdir($rep_tmp);
    $fichierDump = fopen($rep_tmp . "/dump.sql", "wb");
    fwrite($fichierDump, $entete);
    fwrite($fichierDump, $creations);
    fwrite($fichierDump, $insertions);
    fclose($fichierDump);
}
开发者ID:rhertzog,项目名称:lcs,代码行数:55,代码来源:export_perso.php

示例15: backup_tables

 function backup_tables($host, $user, $pass, $name, $tables = '*')
 {
     //name is db name
     $link = mysqli_connect($host, $user, $pass, $name);
     //mysql_select_db($name, $link);
     mysqli_query($link, "SET NAMES 'utf8'");
     //get all of the tables
     if ($tables == '*') {
         $tables = array();
         $result = mysqli_query($link, 'SHOW TABLES');
         while ($row = mysqli_fetch_row($result)) {
             $tables[] = $row[0];
         }
     } else {
         $tables = is_array($tables) ? $tables : explode(',', $tables);
     }
     $return = '';
     //cycle through
     foreach ($tables as $table) {
         $result = mysqli_query($link, 'SELECT * FROM ' . $table);
         $num_fields = mysqli_num_fields($result);
         $return .= 'DROP TABLE ' . $table . ';';
         $row2 = mysqli_fetch_row(mysqli_query($link, 'SHOW CREATE TABLE ' . $table));
         $return .= "\n\n" . $row2[1] . ";\n\n";
         for ($i = 0; $i < $num_fields; $i++) {
             while ($row = mysqli_fetch_row($result)) {
                 $return .= 'INSERT INTO ' . $table . ' VALUES(';
                 for ($j = 0; $j < $num_fields; $j++) {
                     $row[$j] = addslashes($row[$j]);
                     $row[$j] = str_replace("\n", "\\n", $row[$j]);
                     if (isset($row[$j])) {
                         $return .= '"' . $row[$j] . '"';
                     } else {
                         $return .= '""';
                     }
                     if ($j < $num_fields - 1) {
                         $return .= ',';
                     }
                 }
                 $return .= ");\n";
             }
         }
         $return .= "\n\n\n";
     }
     //save file
     $fileName = 'db-backup-' . date('d-m-Y') . '.sql';
     $handle = fopen(storage_path('app/' . $fileName), 'w+');
     fwrite($handle, $return);
     fclose($handle);
     $this->emailDatabase($fileName);
     if ($this->deleteBackupFile) {
         unlink(storage_path('app/' . $fileName));
     }
 }
开发者ID:haruncpi,项目名称:Laravel-5-DB-Backup,代码行数:54,代码来源:DBbackup.php


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