function give_image($db_con, $ident, $picname) { $query = "select `image` from `satpics` where " . "`ident`='" . mysql_real_escape_string($ident) . "' and `picname`='" . mysql_real_escape_string($picname) . "'"; $res = mysql_query($query, $db_con); $nrows = mysql_num_rows($res); if ($nrows > 0) { $row_array = mysql_fetch_row($res); $len_array = mysql_fetch_lengths($res); echo "LEN " . $len_array[0] . "\r\nx"; echo bin2hex($row_array[0]); } }
public function fetch($query, $type = SEBODB_ASSOC) { $r = false; if (!is_resource($query)) { trigger_error('SeboDB:SQLite argument provided is not a valid result resource', E_USER_WARNING); } if ($type === SEBODB_ARRAY) { $r = sqlite_fetch_array($query, SQLITE_NUM); } elseif ($type === SEBODB_ASSOC) { $r = sqlite_fetch_array($query, SQLITE_ASSOC); } elseif ($type === SEBODB_OBJECT) { $r = sqlite_fetch_object($query); } elseif ($type === SEBODB_FIELD) { // FINISH ME FINISH ME FINISH ME $r = sqlite_fetch_array($query); } elseif ($type === SEBODB_LENGTHS) { $r = mysql_fetch_lengths($query); } else { trigger_error('SeboDB:SQLite invalid type argument', E_USER_WARNING); } return $r; }
public function fetchOne() { if ($this->usemysqli) { switch ($this->fetchMode) { case __ARRAY: $result = mysqli_fetch_array($this->result); break; case __ASSOCARRAY: $result = mysqli_fetch_assoc($this->result); break; case __FIELDDIRECT: $result = mysqli_fetch_field_direct($this->result, $this->fetchFieldDirectFieldNr); break; case __FIELD: $result = mysqli_fetch_field($this->result); break; case __FIELDS: $result = mysqli_fetch_fields($this->result); break; case __LENGTHS: $result = mysqli_fetch_lengths($this->result); break; case __OBJECT: $result = mysqli_fetch_object($this->result); break; case __ROW: $result = mysqli_fetch_row($this->result); break; default: $result = null; break; } return $result; } else { switch ($this->fetchMode) { case __ARRAY: $result = mysql_fetch_array($this->result); break; case __ASSOCARRAY: $result = mysql_fetch_assoc($this->result); break; case __FIELDDIRECT: $result = NULL; break; case __FIELD: $result = mysql_fetch_field($this->result); break; case __FIELDS: $result = NULL; break; case __LENGTHS: $result = mysql_fetch_lengths($this->result); break; case __OBJECT: $result = mysql_fetch_object($this->result); break; case __ROW: $result = mysql_fetch_row($this->result); break; default: $result = null; break; } return $result; } }
public function fetch_lengths(&$result) { if (!is_resource($result)) { return false; } return @mysql_fetch_lengths($result); }
function FetchLengths($resultado){ $this->resultado = $resultado; return @mysql_fetch_lengths($this->resultado); }
switch (DB_EXTENSION) { case "mysql": $ret = mysql_fetch_array($result); break; case "mysqli": $ret = mysqli_fetch_array($result); break; } return $ret; } function yog_mysql_fetch_lengths($result) { //Get the length of each output in a result $ret = array();
printf("FAILURE: insert records into table nobody, [%d] %s\n", mysql_errno($con), mysql_error($con)); } if (!($res = mysql_query("SELECT id, msg FROM nobody ORDER BY id ASC", $con))) { printf("FAILURE: cannot fetch records, [%d] %s\n", mysql_errno($con), mysql_error($con)); } if (!($row = mysql_fetch_assoc($res))) { printf("FAILURE: cannot fetch first row, [%d] %s\n", mysql_errno($con), mysql_error($con)); } $lengths = mysql_fetch_lengths($res); if (!is_array($lengths)) { printf("FAILURE: expecting array, got %s value, [%d] %s\n", gettype($lengths), mysql_errno($con), mysql_error($con)); } if ($lengths[0] != 1) { printf("FAILURE: expecting length 1 for field 'id', got length %d [%d] %s\n", $lengths[0], mysql_errno($con), mysql_error($con)); } $lengths = mysql_fetch_lengths($illegal_result_identifier); if (!is_bool($lengths)) { printf("FAILURE: expecting boolean, got %s value, [%d] %s\n", gettype($lengths), mysql_errno($con), mysql_error($con)); } if ($lengths) { printf("FAILURE: expecting false, [%d] %s\n", mysql_errno($con), mysql_error($con)); } mysql_free_result($res); mysql_close($con); ?> --EXPECT-EXT/MYSQL-OUTPUT-- SUCCESS: connect --EXPECT-EXT/MYSQL-PHP-ERRORS-- --EXPECT-EXT/MYSQLI-OUTPUT-- SUCCESS: connect
<?php require_once 'connect.inc'; $conn = mysql_connect($host, $user, $passwd); var_dump(create_test_table('lengths')); var_dump(mysql_query("insert into test_lengths (name) values ('test'),('test2')")); $res = mysql_query('select * from test_lengths'); $row = mysql_fetch_row($res); $lengths = mysql_fetch_lengths($res); print_r($lengths); // A much more intense test on lengths mysql_query('drop table testlen'); var_dump(mysql_query("create table testlen (id int not null auto_increment, " . "d decimal(10,5), t tinyint, i int, b bigint, f float, " . "db double, y2 year(2), y4 year(4), primary key (id)) " . "engine=innodb")); var_dump(mysql_query("insert into testlen(d, t, i, b, f, db, y2, y4) values" . "(.343, null, 384, -1, 03.44, -03.43892874e101, 00, 0000)")); $res = mysql_query('select * from testlen'); $row = mysql_fetch_row($res); $lengths = mysql_fetch_lengths($res); print_r($lengths);
function xf_db_fetch_lengths($result) { return mysql_fetch_lengths($result); }
SendPacket($Packet); } $Packet = ''; $Packet .= "þ"; $Packet .= pack('v', 0); // WarningCount if ($MorePackets) { $Packet .= pack('v', 0x8); } else { $Packet .= pack('v', 0x0); } // Server Status SendPacket($Packet); while ($Row = mysql_fetch_array($result, MYSQL_NUM)) { $Packet = ''; $Lengths = mysql_fetch_lengths($result); for ($i = 0; $i < mysql_num_fields($result); $i++) { if (!isset($Row[$i])) { $Packet .= "û"; } else { $Packet .= PackLength($Lengths[$i]) . $Row[$i]; } } SendPacket($Packet); } mysql_free_result($result); $Packet = ''; $Packet .= "þ"; $Packet .= pack('v', 0); // WarningCount if ($MorePackets) {
function fetch_lengths() { return mysql_fetch_lengths($this->res); }
public function deleteUsuario() { $sqlDeleteUsuario = "DELETE FROM tblusuario WHERE idUsuario=" . $this->idUsuario; try { $resultadoDeleteUsuario = mysql_query($sqlDeleteUsuario) or die(RETURN_SQL . mysql_error()); if (mysql_fetch_lengths($resultadoDeleteUsuario) > 0) { echo "Excluído com sucesso"; } mysql_close($resultadoDeleteUsuario); } catch (Exception $ex) { } }
function ExecuteSingleQuery($mysql, $query) { global $tunnelversion; $result = mysql_query($query, $mysql); WriteLog("Enter ExecuteSingleQuery"); if (!$result) { HandleError(mysql_errno(), mysql_error()); return; } /* query execute was successful so we need to echo the correct xml */ /* the query may or may not return any result */ WriteLog("mysql_num_rows in ExecuteSingleQuery"); if (!mysql_num_rows($result) && !mysql_num_fields($result)) { /* is a non-result query */ echo "<xml v=\"" . $tunnelversion . "\">"; echo "<e_i></e_i>"; HandleExtraInfo($mysql); echo "<f_i c=\"0\"></f_i><r_i></r_i></xml>"; return; } /* handle result query like SELECT,SHOW,EXPLAIN or DESCRIBE */ echo '<xml v="' . $tunnelversion . '">'; echo "<e_i></e_i>"; /* add some extra info */ HandleExtraInfo($mysql); /* add the field count information */ $fieldcount = mysql_num_fields($result); print $fieldcount; echo "<f_i c=\"{$fieldcount}\">"; /* retrieve information about each fields */ $i = 0; while ($i < $fieldcount) { $meta = mysql_fetch_field($result); echo "<f>"; echo "<n>" . convertxmlchars($meta->name) . "</n>"; echo "<t>" . convertxmlchars($meta->table) . "</t>"; echo "<m>" . convertxmlchars($meta->max_length) . "</m>"; echo "<d></d>"; echo "<ty>" . GetCorrectDataType($result, $i) . "</ty>"; echo "</f>"; $i++; } /* end field informations */ echo "</f_i>"; /* get information about number of rows in the resultset */ $numrows = mysql_num_rows($result); echo "<r_i c=\"{$numrows}\">"; /* add up each row information */ while ($row = mysql_fetch_array($result)) { $lengths = mysql_fetch_lengths($result); /* start of a row */ echo "<r>"; for ($i = 0; $i < $fieldcount; $i++) { /* start of a col */ echo "<c l=\"{$lengths[$i]}\">"; if (!isset($row[$i])) { echo "(NULL)"; } else { if (mysql_field_type($result, $i) == "blob") { if ($lengths[$i] == 0) { echo "_"; } else { echo convertxmlchars(base64_encode($row[$i])); } } else { if ($lengths[$i] == 0) { echo "_"; } else { echo convertxmlchars($row[$i]); } } } /* end of a col */ echo "</c>"; } /* end of a row */ echo "</r>"; } /* close the xml output */ echo "</r_i></xml>"; /* free the result */ mysql_free_result($result); WriteLog("Exit ExecuteSingleQuery"); }
public static function fetch() { $return = func_get_arg(0); $sql = func_get_arg(1); if (!$sql) { return false; } $fct_list = array('array', 'assoc', 'field', 'lengths', 'object', 'row'); if (!in_array($return, $fct_list)) { $return = 'array'; } // retourne une ligne de résultat mysql sous la forme d'un tableau associatif (MYSQL_ASSOC), d'un tableau indexé (MYSQL_NUM), ou les deux (MYSQL_BOTH) if ($return == 'array') { $result_type = func_num_args() >= 3 ? func_get_arg(2) : MYSQL_BOTH; //$this->driver->fetch_array() return mysql_fetch_array($sql, $result_type); } else { if ($return == 'assoc') { //$this->driver->fetch_assoc() return mysql_fetch_assoc($sql); } else { if ($return == 'field') { // la position numérique du champ // cf. http://fr3.php.net/manual/fr/function.mysql-fetch-field.php $field_offset = func_num_args() >= 3 ? func_get_arg(2) : 0; //$this->driver->fetch_field() return mysql_fetch_field($sql, $field_offset); } else { if ($return == 'lengths') { //$this->driver->fetch_lengths() return mysql_fetch_lengths($sql); } else { if ($return == 'object') { // le nom de la class à instancier $class_name = func_num_args() >= 3 ? func_get_arg(2) : 'stdClass'; // un tableau contenant les paramètres à passer au contructeur de la class $class_name $params = func_num_args() >= 4 ? func_get_arg(3) : false; if ($params) { //$this->driver->fetch_object() return mysql_fetch_object($sql, $class_name, $params); } else { //$this->driver->fetch_object() return mysql_fetch_object($sql, $class_name); } } else { if ($return == 'row') { //$this->driver->fetch_row() return mysql_fetch_row($sql); } } } } } } }
/** * Fetches a row from the query resource provided * @access public * @param resource $query Query resource * @param integer $type Use a SEBODB_ constant to have the function fetch different types of data * @return mixed Returns the type of data specified by $type, an associative array by default, if successful, false otherwise */ public function fetch(&$query, $type = SEBODB_ASSOC) { $r = false; // Return what $type asks for if ($type === SEBODB_ARRAY) { $r = @mysql_fetch_row($query); } elseif ($type === SEBODB_ASSOC) { $r = @mysql_fetch_assoc($query); } elseif ($type === SEBODB_OBJECT) { $r = @mysql_fetch_object($query); } elseif ($type === SEBODB_FIELD) { $r = @mysql_fetch_field($query); } elseif ($type === SEBODB_LENGTHS) { $r = @mysql_fetch_lengths($query); } else { throw new SeboDBDriverException('Return type specified for fetch() is invalid'); } return $r; }
<?php include "connect.inc"; $tmp = NULL; $link = NULL; if (!is_null($tmp = @mysql_fetch_lengths())) { printf("[001] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); } if (NULL !== ($tmp = @mysql_fetch_lengths($link))) { printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp); } require 'table.inc'; if (!($res = mysql_query("SELECT id, label FROM test ORDER BY id LIMIT 1", $link))) { printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link)); } while ($row = mysql_fetch_assoc($res)) { var_dump(mysql_fetch_lengths($res)); } var_dump(mysql_fetch_lengths($res)); mysql_free_result($res); var_dump(mysql_fetch_lengths($res)); mysql_close($link); print "done!"; require_once "clean_table.inc";
function fetchLengths() { /* 取得结果集中每个输出的长度 */ return @mysql_fetch_lengths($this->Result); }
/** * fetch the value lengths of the last row. * * @access public * @return array */ public function fetchLengths() { return @mysql_fetch_lengths($this->result); }
/** * Test mysql_fetch_lengths * * @return boolean */ public function MySQL_Fetch_Lengths_Test() { $sql = 'SELECT * FROM ' . TEST_TABLE; $query1 = mysql_query($sql); $query2 = $this->_object->mysql_query($sql); while ($row = mysql_fetch_row($query1)) { $row2 = mysql_fetch_lengths($query1); foreach ($row as $sub => $string) { if (strlen($string) != $row2[$sub]) { return false; } } } while ($row = $this->_object->mysql_fetch_row($query2)) { $row2 = $this->_object->mysql_fetch_lengths($query1); foreach ($row as $sub => $string) { if (strlen($string) != $row2[$sub]) { return false; } } } return true; }
protected function fetchLength($query) { $result = mysql_fetch_lengths($query); return $result; }