Exemple #1
0
 public function query($sql)
 {
     $pos = stripos($sql, 'select');
     if (is_numeric($pos)) {
         //是select 语句
         $rs = mysqli_query($this->conn, $sql);
         if (mysqli_errno($this->conn)) {
             die('you have an error ' . mysqli_error($this->conn));
         }
         if ($rs === false) {
             return mysqli_affected_rows($this->conn);
         }
         //什么时候返回是false呢...哦子查询是select
         $columns = array();
         while ($property = @mysqli_fetch_field($rs)) {
             $columns[] = $property->name;
         }
         $arr = array();
         while ($result = @mysqli_fetch_row($rs)) {
             $arr[] = array_combine($columns, $result);
         }
         return $arr;
     } else {
         mysqli_query($this->conn, $sql);
         if (mysqli_errno($this->conn)) {
             die('you have an error ' . mysqli_error($this->conn));
         }
         return mysqli_affected_rows($this->conn);
     }
 }
 /**
  * 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);
     }
 }
 public function algorithm(array $dataPack)
 {
     $this->tableMaster = IStrategy::TABLENOW;
     $this->hookup = UniversalConnect::doConnect();
     //Create Query Statement
     $sql = "SELECT * FROM {$this->tableMaster}";
     //Conditional statement in MySQL command
     if ($result = $this->hookup->query($sql)) {
         printf("Select returned %d rows.<p />", $result->num_rows);
         echo "<link rel='stylesheet' href='main.css'>";
         echo "<table>";
         while ($finfo = mysqli_fetch_field($result)) {
             echo "<th>&nbsp;{$finfo->name}</th>";
         }
         echo "</tr>\n";
         while ($row = mysqli_fetch_row($result)) {
             echo "<tr >";
             foreach ($row as $cell) {
                 echo "<td >{$cell}</td>";
             }
             echo "</tr>";
         }
         echo "</table>";
         $result->close();
     }
     $this->hookup->close();
 }
Exemple #4
0
 /** Custom SQL Query **/
 function query($query, $singleResult = 0)
 {
     $this->_result = mysqli_query($query, $this->_dbHandle);
     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) {
             array_push($table, mysqli_fetch_field($this->_result, $i));
             array_push($field, mysqli_fetch_field($this->_result, $i));
         }
         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;
     }
 }
 public function getValue($sSQL)
 {
     $oQuery = mysqli_query($this->_connection, $sSQL);
     if ($oQuery) {
         return mysqli_fetch_field($oQuery);
     }
     return false;
 }
 /**
  * Fetch Field Names
  *
  * Generates an array of column names
  *
  * @access    public
  * @return    array
  */
 function list_fields()
 {
     $field_names = array();
     while ($field = mysqli_fetch_field($this->result_id)) {
         $field_names[] = $field->name;
     }
     return $field_names;
 }
Exemple #7
0
 /**
  * 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);
 }
Exemple #8
0
 public function get_fields($result_set)
 {
     $columnNames = array();
     $fieldMetadata = mysqli_fetch_field($result_set);
     foreach ($fieldMetadata as $value) {
         array_push($columnNames, $value);
         break;
     }
     return $columnNames;
 }
 function GetFields()
 {
     $_fields = array();
     $_result = mysqli_query($this->_Link, $this->SelectCommand);
     while ($_prop = mysqli_fetch_field($_result)) {
         $_field = array("Name" => $_prop->name, "Type" => $_prop->type, "Not_Null" => 0);
         array_push($_fields, $_field);
     }
     return $_fields;
 }
Exemple #10
0
 private function stmt_assoc(&$stmt, array &$out)
 {
     $data = mysqli_stmt_result_metadata($stmt);
     $fields = array($this->_STMT);
     $out = array();
     while ($field = mysqli_fetch_field($data)) {
         $fields[] =& $out[$field->name];
     }
     call_user_func_array('mysqli_stmt_bind_result', $fields);
 }
function SQL($Query)
{
    global $DB;
    $args = func_get_args();
    if (count($args) == 1) {
        $result = $DB->query($Query);
        if ($result->num_rows) {
            $out = array();
            while (null != ($r = $result->fetch_array(MYSQLI_ASSOC))) {
                $out[] = $r;
            }
            return $out;
        }
        return null;
    } else {
        if (!($stmt = $DB->prepare($Query))) {
            trigger_error("Unable to prepare statement: {$Query}, reason: " . $DB->error . "");
        }
        array_shift($args);
        //remove $Query from args
        //the following three lines are the only way to copy an array values in PHP
        $a = array();
        foreach ($args as $k => &$v) {
            $a[$k] =& $v;
        }
        $types = str_repeat("s", count($args));
        //all params are strings, works well on MySQL and SQLite
        array_unshift($a, $types);
        call_user_func_array(array($stmt, 'bind_param'), $a);
        $stmt->execute();
        //fetching all results in a 2D array
        $metadata = $stmt->result_metadata();
        $out = array();
        $fields = array();
        if (!$metadata) {
            return null;
        }
        $length = 0;
        while (null != ($field = mysqli_fetch_field($metadata))) {
            $fields[] =& $out[$field->name];
            $length += $field->length;
        }
        call_user_func_array(array($stmt, "bind_result"), $fields);
        $output = array();
        $count = 0;
        while ($stmt->fetch()) {
            foreach ($out as $k => $v) {
                $output[$count][$k] = $v;
            }
            $count++;
        }
        $stmt->free_result();
        return $output;
    }
}
 /**
  * @param String stype
  * @return Number
  */
 public function db_getfieldslist($strSQL)
 {
     $res = array();
     $rs = mysqli_query($this->connectionObj->conn, $strSQL);
     while ($finfo = mysqli_fetch_field($rs)) {
         $stype = $this->getFieldTypeNumber($finfo->type, $finfo->flags);
         $res[] = array("fieldname" => $finfo->name, "type" => $stype, "not_null" => 0);
     }
     $rs->close();
     return $res;
 }
Exemple #13
0
function createQuery($table, $q, $starting, $add)
{
    global $mysqli;
    $getTableFields = $mysqli->query("SELECT * FROM " . $table);
    $query = $starting;
    while ($fields = mysqli_fetch_field($getTableFields)) {
        $query .= $fields->name . " LIKE '%" . $q . "%' OR ";
    }
    $query = substr($query, 0, -3);
    $query .= $add ? ")" : "";
    return $mysqli->query($query);
}
Exemple #14
0
 /**
  * Structure of our fields (type, length and null)
  *
  * @param resource $resource
  * @return array
  */
 public function field_structures($resource)
 {
     $result = [];
     if ($resource) {
         while ($finfo = mysqli_fetch_field($resource)) {
             $result[$finfo->name]['type'] = $this->field_type($finfo->type);
             $result[$finfo->name]['null'] = $finfo->flags & 1 ? false : true;
             $result[$finfo->name]['length'] = $finfo->length;
         }
     }
     return $result;
 }
function stmt_bind_assoc(&$stmt, &$out)
{
    $data = mysqli_stmt_result_metadata($stmt);
    $fields = array();
    $out = array();
    $fields[0] = $stmt;
    $count = 1;
    while ($field = mysqli_fetch_field($data)) {
        $fields[$count] =& $out[$field->name];
        $count++;
    }
    call_user_func_array(mysqli_stmt_bind_result, $fields);
}
function db_getfieldslist($strSQL)
{
	global $conn;
	$res=array();
	$rs = mysqli_query($conn, $strSQL);
	while($finfo = mysqli_fetch_field($rs)) 
	{
		$stype=db_fieldtypenum($finfo->type,$finfo->flags);
		$res[]=array("fieldname"=>$finfo->name,"type"=>$stype,"not_null"=>0);
	}
	$rs->close();
	return $res;
}
Exemple #17
0
 /**
  * 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);
     while ($field = mysqli_fetch_field($d)) {
         $this->columns[] = $field->name;
     }
     if (mysqli_num_rows($d) > 0) {
         mysqli_data_seek($d, 0);
         while ($line = mysqli_fetch_row($d)) {
             $this->rows[] = $line;
         }
     }
 }
Exemple #18
0
 /**
  * @param $data - mysqli result
  * @param $title - true / false (show or not the title)
  * @return string
  */
 public function query_output($data)
 {
     if (!$data) {
         $table_output = 'No data to display, quitting.<br>';
         return 'error in htmloutput.php library class: query argument required';
     }
     //$table_output = 'Data was passed to query_output method.<br>';
     // $table_output = $table_output.'------------------------------------------------------------------------------------------------------------------------------------<br>';
     // display columns field names
     $i = 0;
     $table_output = '<html><body><table><tr>';
     while ($i < mysqli_num_fields($data)) {
         $meta = mysqli_fetch_field($data);
         if ($title == 'true') {
             $table_output = $table_output . '<td>' . $meta->name . '</td>';
         }
         $i = $i + 1;
     }
     $table_output = $table_output . '</tr>';
     // SHOULD Display only the selected range, thus making 'pages'.
     //$i     = $range['first_row'];
     //$count = $range['last_row'];
     // echo "from htmloutput.php: from ".$range['first_row']." to ".$range['last_row']." rows.<br>";
     //mysqli_data_seek($data, $range['first_row']);
     //if ($range['last_row'] !== -1 ) {
     //    $last_row = $range['last_row'];
     //} else {
     //    $last_row = mysqli_num_rows ($data);
     //}
     //$r = $range['first_row'];
     $r = 0;
     $last_row = mysqli_num_rows($data);
     while ($r < $last_row) {
         $row = mysqli_fetch_row($data);
         $table_output .= '<tr>';
         $count = count($row);
         $y = 0;
         //columns
         while ($y < $count) {
             $c_row = current($row);
             $table_output .= '<td>' . $c_row . '</td>';
             next($row);
             $y = $y + 1;
             // walk the columns one by one
         }
         $table_output .= '</tr>';
         $r = $r + 1;
     }
     echo '</table></body></html>';
     return $table_output;
 }
 /**
  * Field data
  *
  * Generates an array of objects containing field meta-data
  *
  * @access	public
  * @return	array
  */
 function field_data()
 {
     $retval = array();
     while ($field = mysqli_fetch_field($this->result_id)) {
         $F = new stdClass();
         $F->name = $field->name;
         $F->type = $field->type;
         $F->default = $field->def;
         $F->max_length = $field->max_length;
         $F->primary_key = $field->flags & MYSQLI_PRI_KEY_FLAG ? 1 : 0;
         $retval[] = $F;
     }
     return $retval;
 }
Exemple #20
0
function read($tabela, $cond = null)
{
    $con = mysqli_connect(HOST, USER, PASS, DBAS) or die(mysqli_error($con) . "Não foi possível fazer a conexão com o sistema");
    $qrRead = "SELECT * FROM {$tabela} {$cond}";
    $stRead = mysqli_query($con, $qrRead);
    $cFields = mysqli_num_fields($stRead);
    for ($y = 0; $y < $cFields; $y++) {
        $n = mysqli_fetch_field($stRead);
        $names[$y] = $n->name;
    }
    for ($x = 0; $x < ($res = mysqli_fetch_assoc($stRead)); $x++) {
        for ($i = 0; $i < $cFields; $i++) {
            $resultado[$x][$names[$i]] = $res[$names[$i]];
        }
    }
    return $resultado;
    mysqli_close($con);
}
Exemple #21
0
function sqlToArray($connection, $query, $blockedFields = array())
{
    if (trim($query) == "") {
        return array();
    }
    mysqli_set_charset($connection, "utf8");
    $sql_query = mysqli_query($connection, $query);
    $masterArray = array();
    $columnArray = array();
    while ($fld = mysqli_fetch_field($sql_query)) {
        $fieldname = $fld->name;
        // The field name of the current column
        if (!in_array($fieldname, $blockedFields)) {
            array_push($columnArray, $fieldname);
        }
    }
    while ($row = mysqli_fetch_array($sql_query)) {
        $newArray = array();
        for ($i = 0; $i < count($columnArray); $i++) {
            $newArray = array_merge($newArray, array($columnArray[$i] => ""));
        }
        foreach ($newArray as $k => $v) {
            $key = trim(strtolower($k));
            //All json arrays or blob objects
            $nono_list = array("profile_pic", "image", "offers", "who_ranked", "messages", "availability", "privacy", "rank", "last_location");
            if (in_array($key, $nono_list)) {
                if (is_array(json_decode($row[$k], true))) {
                    $newArray[$k] = json_encode(purify_array(json_decode($row[$k], true)));
                } else {
                    $newArray[$k] = $row[$k];
                }
            } else {
                $newArray[$k] = htmlentities($row[$k]);
            }
            if (isset($newArray["fname"]) && isset($newArray["lname"])) {
                $newArray["fname"] = ucwords($newArray["fname"]);
                $newArray["lname"] = ucwords($newArray["lname"]);
            }
        }
        array_push($masterArray, $newArray);
    }
    return $masterArray;
}
function mysqli_field_datatypes($link, $sql_type, $php_value, $php_type, $datatypes, $default_charset = "latin1")
{
    if (!mysqli_query($link, "DROP TABLE IF EXISTS test")) {
        printf("[001] %s, [%d] %s\n", $sql_type, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    $create = sprintf("CREATE TABLE test(id %s) DEFAULT CHARSET %s", $sql_type, $default_charset);
    if (!mysqli_query($link, $create)) {
        printf("[002] '%s' - '%s', [%d] %s\n", $sql_type, $create, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if (is_string($php_value)) {
        $sql = sprintf("INSERT INTO test(id) VALUES ('%s')", $php_value);
    } else {
        $sql = sprintf("INSERT INTO test(id) VALUES (%s)", $php_value);
    }
    if (!mysqli_query($link, $sql)) {
        printf("[003] '%s' - '%s' - '%s', [%d] %s\n", $sql_type, $create, $sql, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if (!($res = mysqli_query($link, 'SELECT id FROM test'))) {
        printf("[004] %s, [%d] %s\n", $sql_type, mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if (!is_object($field = mysqli_fetch_field($res))) {
        printf("[004] %s, expecting object got %s, [%d] %s\n", $sql_type, gettype($field), mysqli_errno($link), mysqli_error($link));
        return false;
    }
    if ($field->type != $php_type) {
        $code_name = 'unknown';
        foreach ($datatypes as $k => $v) {
            if ($k == $field->type) {
                $code_name = is_array($v) ? $v[0] : $v;
                break;
            }
        }
        printf("[006] Expecting %d for %s got code %d for %s\n", $php_type, $sql_type, $field->type, $code_name);
        return false;
    }
    return true;
}
Exemple #23
0
function PrintTable($result)
{
    if (@mysqli_num_rows($result) == 0) {
        echo "<b>Nenhum resultado retornado.</b><br>";
    } else {
        echo "<table border='1' class='tablesorter striped'> \n\t\t\t\t<thead> \n\t\t\t\t<tr>";
        for ($i = 0; $i < mysqli_num_fields($result); $i++) {
            $name = mysqli_fetch_field($result)->name;
            echo "<th id='" . $name . "'>" . $name . "</th>";
        }
        echo "</tr> \n\t\t\t\t</thead> \n\t\t\t\t<tbody>";
        for ($i = 0; $i < mysqli_num_rows($result); $i++) {
            echo "<tr>";
            $row = mysqli_fetch_row($result);
            for ($j = 0; $j < mysqli_num_fields($result); $j++) {
                echo "<td>" . $row[$j] . "</td>";
            }
            echo "</tr>";
        }
        echo "</tbody> \n\t\t\t\t</table>";
    }
}
Exemple #24
0
function dohvatiPod($baza, $id, $table, $tip)
{
    $upit = "Select * from " . $table . "";
    $podaci = $baza->selectUpit($upit);
    $j = 0;
    while ($data = mysqli_fetch_field($podaci)) {
        $th[$j] = $data->name;
        $j = $j + 1;
    }
    $upit_2 = "Select * from " . $table . " Where " . $th[0] . "='{$id}'";
    if ($table == "Korisnik") {
        $upit_2 = "Select * from " . $table . " Where " . $th[5] . "='{$id}'";
    }
    $podaci_2 = $baza->selectUpit($upit_2);
    $i = 0;
    while ($red = $podaci_2->fetch_array()) {
        for ($z = 0; $z < $j; $z++) {
            $response[$i][$th[$z]] = $red[$th[$z]];
        }
        $i = $i + 1;
    }
    return json_encode($response);
}
Exemple #25
0
 public function algorithm(array $dataPack)
 {
     $this->tableMaster = IStrategy::TABLENOW;
     $this->hookup = UniversalConnect::doConnect();
     $this->sql = "SELECT * FROM {$this->tableMaster}";
     if ($result = $this->hookup->query($this->sql)) {
         printf("Zwrócono %d wierszy. <p/>", $result->num_rows);
         echo "<table><tr>";
         while ($finfo = mysqli_fetch_field($result)) {
             echo "<th>{$finfo->name}</th>";
         }
         echo "</tr>\n";
         while ($row = mysqli_fetch_row($result)) {
             echo "<tr>";
             foreach ($row as $cell) {
                 echo "<td>{$cell}</td>";
             }
             echo "</tr>";
         }
         echo "</table>";
         $result->close();
     }
     $this->hookup->close();
 }
Exemple #26
0
function PrintImgTable($result, $table)
{
    if (@mysqli_num_rows($result) == 0) {
        echo "<b>Nenhum resultado retornado.</b><br>";
    } else {
        echo "<table border='1' class='col l9 offset-l2 s12 tablesorter centered striped'>\n\t\t\t\t<thead>\n\t\t\t\t<tr>";
        for ($i = 0; $i < mysqli_num_fields($result); $i++) {
            $name = mysqli_fetch_field($result)->name;
            echo "<th id='" . $name . "'>" . $name . "</th>";
        }
        echo "<th id='img_file'>img_file</th>";
        if ($_SESSION['usuarioRoot'] == 'Y') {
            echo "<th id='edit' >Alterar</th>";
        }
        echo "</tr>\n\t\t\t\t</thead>\n\t\t\t\t<tbody>";
        for ($i = 0; $i < mysqli_num_rows($result); $i++) {
            echo "<tr>";
            $row = mysqli_fetch_row($result);
            for ($j = 0; $j < mysqli_num_fields($result); $j++) {
                echo "<td>" . $row[$j] . "</td>";
            }
            echo "<td >";
            echo "<img src='/coneti/relatorio/ver-imagens.php?tipo=" . $table . "&id=" . $row[0] . "' class='col s12 materialboxed responssive-img'>";
            echo "</td>";
            if ($_SESSION['usuarioRoot'] == 'Y') {
                echo "<td  id='edit" . $i . "'>";
                echo "<a href='#' onClick='alteraTupla(\"" . $row[0] . "\")'>Alterar</a>";
                echo "</td></tr>";
            }
        }
        echo "</tbody>\n\t\t\t\t</table>";
    }
}
Exemple #27
0
    if (isset($_GET["id"])) {
        echo "<div id='" . $_GET["id"] . "'>" . $_GET["v"] . "</div>";
    }
    ?>
 
              <div id="right-panel">  
              
              <?php 
    include "db.php";
    $connectionStatus = connect_db();
    $query1 = "select myid from friends";
    $query2 = "select status from friends";
    $result1 = mysqli_query($connectionStatus, $query1);
    $info1 = mysqli_fetch_field($result1);
    $result2 = mysqli_query($connectionStatus, $query2);
    $info2 = mysqli_fetch_field($result2);
    $myid = $info1->name;
    $status = $info2->name;
    $myid1 = $_SESSION['id'];
    $connectionStatus1 = connect_db();
    $q = "SELECT * FROM friends where myid='{$myid1}' AND status='F'";
    $result1 = mysqli_query($connectionStatus1, $q);
    if (mysqli_affected_rows($connectionStatus1) != 0) {
        $id5 = 0;
        echo "<table>";
        echo "<tr>";
        echo "<th>ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th> <th>First Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th> <th>Last Name&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Batch&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>Degree</th>";
        //$d = mysqli_fetch_assoc($result1);
        //$id=$d["friendid"];
        while ($d = mysqli_fetch_assoc($result1)) {
            $id = $d["friendid"];
Exemple #28
0
 /**
  * Fetch field information for a table. 
  *
  * @return object containing the name, type and max_length
  */
 function FetchField($fieldOffset = -1)
 {
     if (EW_USE_MYSQLI) {
         // $fieldOffset not supported by mysqli
         $fieldObject = @mysqli_fetch_field($this->resultId);
     } else {
         if ($fieldOffset != -1) {
             $fieldObject = @mysql_fetch_field($this->resultId, $fieldOffset);
             $fieldObject->max_length = @mysql_field_len($this->resultId, $fieldOffset);
         } else {
             $fieldObject = @mysql_fetch_field($this->resultId);
             $fieldObject->max_length = @mysql_field_len($this->resultId);
         }
     }
     return $fieldObject;
 }
Exemple #29
0
 function FetchField($fieldOffset = -1)
 {
     $fieldnr = $fieldOffset;
     if ($fieldOffset != -1) {
         $fieldOffset = @mysqli_field_seek($this->_queryID, $fieldnr);
     }
     $o = @mysqli_fetch_field($this->_queryID);
     if (!$o) {
         return false;
     }
     /* Properties of an ADOFieldObject as set by MetaColumns */
     $o->primary_key = $o->flags & MYSQLI_PRI_KEY_FLAG;
     $o->not_null = $o->flags & MYSQLI_NOT_NULL_FLAG;
     $o->auto_increment = $o->flags & MYSQLI_AUTO_INCREMENT_FLAG;
     $o->binary = $o->flags & MYSQLI_BINARY_FLAG;
     // $o->blob = $o->flags & MYSQLI_BLOB_FLAG; /* not returned by MetaColumns */
     $o->unsigned = $o->flags & MYSQLI_UNSIGNED_FLAG;
     return $o;
 }
Exemple #30
-8
function fn_execSQL($sql, $r = 0)
{
    global $conexao;
    if (mysqli_multi_query($conexao, $sql)) {
        $resultado = mysqli_store_result($conexao);
        if ($resultado) {
            //prepara um array com os campos/colunas da consulta
            $i = 0;
            while ($obj = mysqli_fetch_field($resultado)) {
                $arrayCampos[$i] = $obj->name;
                $i++;
            }
            //prepara um array associativo com o resultado da consulta
            $i = 0;
            while ($linha = mysqli_fetch_array($resultado)) {
                for ($j = 0; $j < count($arrayCampos); $j++) {
                    $retorno[$i][$arrayCampos[$j]] = $linha[$arrayCampos[$j]];
                }
                $i++;
            }
            mysqli_free_result($resultado);
        }
        //mysqli_close($conexao_geral);
        if (isset($retorno)) {
            return $retorno;
        } else {
            return null;
        }
    } else {
        echo "<p>N�o foi poss�vel executar a seguinte instru��o SQL:</p><p><strong>{$sql}</strong></p>\n" . "<p>Erro MySQL: " . mysqli_error($conexao) . "</p>";
        exit;
        //mysqli_close($conexao_geral);
    }
}