kaioh. Postado Novembro 20, 2008 Denunciar Share Postado Novembro 20, 2008 Olá , GalerinhaEu e um amigo meu estamos desenvolvendo um top30 tipo top30 , peguei um script pronto o poblema é que ele não ta aparecendo os sites aonde devia aparecer o unico erro do script alguém pode nos ajudar?www.portugalpet.com.br/top Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 Wanderson Camargo Postado Novembro 20, 2008 Denunciar Share Postado Novembro 20, 2008 Desculpe-me, não somos videntes =PExplique o erro, informe quais as saídas do erro ou algo do gênero; cole o código com erro e no último caso o código completo!Obrigado! Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 kaioh. Postado Novembro 20, 2008 Autor Denunciar Share Postado Novembro 20, 2008 então entra ai na index ai deveria tar aparecendo 1 site que cadastrei e não ta aparecendo e não da nenhum erro o codigo da index é <?require_once('config.php');require_once('layout.php');$objDB=start_db();$objLay=new Layout(HTML_LAYOUT);$objCad=$objLay->open(HTML_RANK);if(!isset($_GET['n'])) $_GET['n']=0;$page=$_GET['n']*PAGINA_RESULTADOS;$arInfo=$objDB->getAll("SELECT cadastros.Id, cadSnome, votos, catNome, if(SUM(log.Id)/log.Id>0,SUM(log.Id)/log.Id,0) as VotoshojeFROM cadastros, categoriasLEFT JOIN log ON (log.Id=cadastros.Id)WHERE cadastros.cadCategoria=categorias.IdGROUP BY cadastros.IdORDER BY votos DESC, Votoshoje DESCLIMIT $page,".PAGINA_RESULTADOS);for($n=0;$n<count($arInfo);$n++){ $arInfo[$n]['n']=(string)(($n+1)+($page)); $arInfo[$n][4]=@(string)(int)$arInfo[$n][4]; $arInfo[$n][1]=@htmlspecialchars($arInfo[$n][1]);}if($_GET['n']>0) $objCad->replace_once('ant',$_GET['n']-1);else $objCad->remove(0);$numpages=$objDB->getOne('SELECT if(FLOOR(COUNT(*)/'.PAGINA_RESULTADOS.')=COUNT(*)/'.PAGINA_RESULTADOS.',FLOOR(COUNT(*)/'.PAGINA_RESULTADOS.'),FLOOR(COUNT(*)/'.PAGINA_RESULTADOS.')+1) FROM cadastros');if($_GET['n']<$numpages-1) $objCad->replace_once('prox',$_GET['n']+1);else $objCad->remove(1);if($numpages>1){ $objNs=$objCad->get_code(0); $objNsn=new Layout; $code=''; for($n=0;$n<$numpages;$n++){ $objNsn->code=$objNs->code; $objNsn->replace_once('n',$n); $objNsn->replace_once('m',$n+1); $code.=$objNsn->code; } $objCad->code_replace(0,$code);}else $objCad->code_remove(0);$objCad->loop_replace('r',$arInfo);$objLay->make($objCad);$objDB->disconnect();?>so que isso não aparece nas categorias também Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 Wanderson Camargo Postado Novembro 20, 2008 Denunciar Share Postado Novembro 20, 2008 Primeiro: no começo desse código coloque a função error_reporting(E_ALL);Segundo verifique se sua SQL está correta ecoando-a na tela antes de enviá-la para o banco e executando-a manualmente.Estou verificando o código...O error_reporting irá aparecer todos os erros que estão acontecendo no script. Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 kaioh. Postado Novembro 20, 2008 Autor Denunciar Share Postado Novembro 20, 2008 coloquei olha la no sitewww.portugalpet.com.br/top apareceu uns erroow codigo das paginas que deram erro sãoDB/common.php :<?php/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */// +----------------------------------------------------------------------+// | PHP Version 4 |// +----------------------------------------------------------------------+// | Copyright © 1997-2003 The PHP Group |// +----------------------------------------------------------------------+// | This source file is subject to version 2.02 of the PHP license, |// | that is bundled with this package in the file LICENSE, and is |// | available at through the world-wide-web at |// | http://www.php.net/license/2_02.txt. |// | If you did not receive a copy of the PHP license and are unable to |// | obtain it through the world-wide-web, please send a note to |// | license@php.net so we can mail you a copy immediately. |// +----------------------------------------------------------------------+// | Author: Stig Bakken <ssb@php.net> |// +----------------------------------------------------------------------+//// $Id: common.php,v 1.21 2003/06/20 20:41:30 cox Exp $//// Base class for DB implementations.///** * DB_common is a base class for DB implementations, and must be * inherited by all such. */require_once "PEAR.php";class DB_common extends PEAR{ // {{{ properties /** * assoc of capabilities for this DB implementation * $features['limit']=> 'emulate' => emulate with fetch row by number * 'alter' => alter the query * false => skip rows * @var array */ var $features; /** * assoc mapping native error codes to DB ones * @var array */ var $errorcode_map; /** * DB type (mysql, oci8, odbc etc.) * @var string */ var $type; /** * @var string */ var $prepare_tokens; /** * @var string */ var $prepare_types; /** * @var string */ var $prepared_queries; /** * @var integer */ var $prepare_maxstmt = 0; /** * @var string */ var $last_query = ''; /** * @var integer */ var $fetchmode = DB_FETCHMODE_ORDERED; /** * @var string */ var $fetchmode_object_class = 'stdClass'; /** * $options["persistent"] -> boolean persistent connection true|false? * $options["optimize"] -> string 'performance' or 'portability' * $options["debug"] -> integer numeric debug level * @var array */ var $options = array( 'persistent' => false, 'optimize' => 'performance', 'debug' => 0, 'seqname_format' => '%s_seq', 'autofree' => false ); /** * DB handle * @var resource */ var $dbh; // }}} // {{{ toString() /** * String conversation * * @return string * @access private */ function toString() { $info = get_class($this); $info .= ": (phptype= . $this->phptype . ", dbsyntax=" . $this->dbsyntax . ")"; if ($this->connection) { $info .= " [connected]"; } return $info; } // }}} // {{{ constructor /** * Constructor */ function DB_common() { $this->PEAR('DB_Error'); $this->features = array(); $this->errorcode_map = array(); $this->fetchmode = DB_FETCHMODE_ORDERED; } // }}} // {{{ quoteString() /** * Quotes a string so it can be safely used within string delimiters * in a query (preserved for compatibility issues, quote() is preffered). * * @return string quoted string * @access public * @see quote() */ function quoteString($string) { $string = $this->quote($string); if ($string{0} == "'") { return substr($string, 1, -1); } return $string; } /** * Quotes a string so it can be safely used in a query. It will return * the string with single quotes around. Other backend quote styles * should override this method. * * @param string $string the input string to quote * * @return string The NULL string or the string quotes * in magic_quote_sybase style */ function quote($string) { return ($string === null) ? 'NULL' : "'".str_replace("'", "''", $string)."'"; } // }}} // {{{ provides() /** * Tell whether a DB implementation or its backend extension * supports a given feature. * * @param array $feature name of the feature (see the DB class doc) * @return bool whether this DB implementation supports $feature * @access public */ function provides($feature) { return $this->features[$feature]; } // }}} // {{{ errorCode() /** * Map native error codes to DB's portable ones. Requires that * the DB implementation's constructor fills in the $errorcode_map * property. * * @param mixed $nativecode the native error code, as returned by the backend * database extension (string or integer) * * @return int a portable DB error code, or FALSE if this DB * implementation has no mapping for the given error code. * * @access public */ function errorCode($nativecode) { if (isset($this->errorcode_map[$nativecode])) { return $this->errorcode_map[$nativecode]; } // Fall back to DB_ERROR if there was no mapping. return DB_ERROR; } // }}} // {{{ errorMessage() /** * Map a DB error code to a textual message. This is actually * just a wrapper for DB::errorMessage(). * * @param integer $dbcode the DB error code * * @return string the corresponding error message, of FALSE * if the error code was unknown * * @access public */ function errorMessage($dbcode) { return DB::errorMessage($this->errorcode_map[$dbcode]); } // }}} // {{{ raiseError() /** * This method is used to communicate an error and invoke error * callbacks etc. Basically a wrapper for PEAR::raiseError * without the message string. * * @param mixed integer error code, or a PEAR error object (all * other parameters are ignored if this parameter is * an object * * @param int error mode, see PEAR_Error docs * * @param mixed If error mode is PEAR_ERROR_TRIGGER, this is the * error level (E_USER_NOTICE etc). If error mode is * PEAR_ERROR_CALLBACK, this is the callback function, * either as a function name, or as an array of an * object and method name. For other error modes this * parameter is ignored. * * @param string Extra debug information. Defaults to the last * query and native error code. * * @param mixed Native error code, integer or string depending the * backend. * * @return object a PEAR error object * * @access public * @see PEAR_Error */ function &raiseError($code = DB_ERROR, $mode = null, $options = null, $userinfo = null, $nativecode = null) { // The error is yet a DB error object if (is_object($code)) { // because we the static PEAR::raiseError, our global // handler should be used if it is set if ($mode === null && !empty($this->_default_error_mode)) { $mode = $this->_default_error_mode; $options = $this->_default_error_options; } return PEAR::raiseError($code, null, $mode, $options, null, null, true); } if ($userinfo === null) { $userinfo = $this->last_query; } if ($nativecode) { $userinfo .= " [nativecode=$nativecode]"; } return PEAR::raiseError(null, $code, $mode, $options, $userinfo, 'DB_Error', true); } // }}} // {{{ setFetchMode() /** * Sets which fetch mode should be used by default on queries * on this connection. * * @param integer $fetchmode DB_FETCHMODE_ORDERED or * DB_FETCHMODE_ASSOC, possibly bit-wise OR'ed with * DB_FETCHMODE_FLIPPED. * * @param string $object_class The class of the object * to be returned by the fetch methods when * the DB_FETCHMODE_OBJECT mode is selected. * If no class is specified by default a cast * to object from the assoc array row will be done. * There is also the posibility to use and extend the * 'DB_Row' class. * * @see DB_FETCHMODE_ORDERED * @see DB_FETCHMODE_ASSOC * @see DB_FETCHMODE_FLIPPED * @see DB_FETCHMODE_OBJECT * @see DB_Row::DB_Row() * @access public */ function setFetchMode($fetchmode, $object_class = null) { switch ($fetchmode) { case DB_FETCHMODE_OBJECT: if ($object_class) { $this->fetchmode_object_class = $object_class; } case DB_FETCHMODE_ORDERED: case DB_FETCHMODE_ASSOC: $this->fetchmode = $fetchmode; break; default: return $this->raiseError('invalid fetchmode mode'); } } // }}} // {{{ setOption() /** * set the option for the db class * * @param string $option option name * @param mixed $value value for the option * * @return mixed DB_OK or DB_Error */ function setOption($option, $value) { if (isset($this->options[$option])) { $this->options[$option] = $value; return DB_OK; } return $this->raiseError("unknown option $option"); } // }}} // {{{ getOption() /** * returns the value of an option * * @param string $option option name * * @return mixed the option value */ function getOption($option) { if (isset($this->options[$option])) { return $this->options[$option]; } return $this->raiseError("unknown option $option"); } // }}} // {{{ prepare() /** * Prepares a query for multiple execution with execute(). * With some database backends, this is emulated. * prepare() requires a generic query as string like * "INSERT INTO numbers VALUES(?,?,?)". The ? are wildcards. * Types of wildcards: * ? - a quoted scalar value, i.e. strings, integers * & - requires a file name, the content of the file * insert into the query (i.e. saving binary data * in a db) * ! - value is inserted 'as is' * * @param string the query to prepare * * @return resource handle for the query * * @access public * @see execute */ function prepare($query) { $tokens = split("[\&\?\!]", $query); $token = 0; $types = array(); $qlen = strlen($query); for ($i = 0; $i < $qlen; $i++) { switch ($query[$i]) { case '?': $types[$token++] = DB_PARAM_SCALAR; break; case '&': $types[$token++] = DB_PARAM_OPAQUE; break; case '!': $types[$token++] = DB_PARAM_MISC; break; } } $this->prepare_tokens[] = &$tokens; end($this->prepare_tokens); $k = key($this->prepare_tokens); $this->prepare_types[$k] = $types; $this->prepared_queries[$k] = &$query; return $k; } // }}} // {{{ autoPrepare() /** * Make automaticaly an insert or update query and call prepare() with it * * @param string $table name of the table * @param array $table_fields ordered array containing the fields names * @param int $mode type of query to make (DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE) * @param string $where in case of update queries, this string will be put after the sql WHERE statement * @return resource handle for the query * @see buildManipSQL * @access public */ function autoPrepare($table, $table_fields, $mode = DB_AUTOQUERY_INSERT, $where = false) { $query = $this->buildManipSQL($table, $table_fields, $mode, $where); return $this->prepare($query); } // {{{ // }}} autoExecute() /** * Make automaticaly an insert or update query and call prepare() and execute() with it * * @param string $table name of the table * @param array $fields_values assoc ($key=>$value) where $key is a field name and $value its value * @param int $mode type of query to make (DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE) * @param string $where in case of update queries, this string will be put after the sql WHERE statement * @return mixed a new DB_Result or a DB_Error when fail * @see buildManipSQL * @see autoPrepare * @access public */ function autoExecute($table, $fields_values, $mode = DB_AUTOQUERY_INSERT, $where = false) { $sth = $this->autoPrepare($table, array_keys($fields_values), $mode, $where); $ret = $this->execute($sth, array_values($fields_values)); $this->freePrepared($sth); return $ret; } // {{{ // }}} buildManipSQL() /** * Make automaticaly an sql query for prepare() * * Example : buildManipSQL('table_sql', array('field1', 'field2', 'field3'), DB_AUTOQUERY_INSERT) * will return the string : INSERT INTO table_sql (field1,field2,field3) VALUES (?,?,?) * NB : - This belongs more to a SQL Builder class, but this is a simple facility * - Be carefull ! If you don't give a $where param with an UPDATE query, all * the records of the table will be updated ! * * @param string $table name of the table * @param array $table_fields ordered array containing the fields names * @param int $mode type of query to make (DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE) * @param string $where in case of update queries, this string will be put after the sql WHERE statement * @return string sql query for prepare() * @access public */ function buildManipSQL($table, $table_fields, $mode, $where = false) { if (count($table_fields) == 0) { $this->raiseError(DB_ERROR_NEED_MORE_DATA); } $first = true; switch ($mode) { case DB_AUTOQUERY_INSERT: $values = ''; $names = ''; while (list(, $value) = each($table_fields)) { if ($first) { $first = false; } else { $names .= ','; $values .= ','; } $names .= $value; $values .= '?'; } return "INSERT INTO $table ($names) VALUES ($values)"; break; case DB_AUTOQUERY_UPDATE: $set = ''; while (list(, $value) = each($table_fields)) { if ($first) { $first = false; } else { $set .= ','; } $set .= "$value = ?"; } $sql = "UPDATE $table SET $set"; if ($where) { $sql .= " WHERE $where"; } return $sql; break; default: $this->raiseError(DB_ERROR_SYNTAX); } } // }}} // {{{ execute() /** * Executes a prepared SQL query * With execute() the generic query of prepare is * assigned with the given data array. The values * of the array inserted into the query in the same * order like the array order * * @param resource $stmt query handle from prepare() * @param array $data numeric array containing the * data to insert into the query * * @return mixed a new DB_Result or a DB_Error when fail * * @access public * @see prepare() */ function &execute($stmt, $data = false) { $realquery = $this->executeEmulateQuery($stmt, $data); if (DB::isError($realquery)) { return $realquery; } $result = $this->simpleQuery($realquery); if (DB::isError($result) || $result === DB_OK) { return $result; } else { return new DB_result($this, $result); } } // }}} // {{{ executeEmulateQuery() /** * Emulates the execute statement, when not supported * * @param resource $stmt query handle from prepare() * @param array $data numeric array containing the * data to insert into the query * * @return mixed a string containing the real query run when emulating * prepare/execute. A DB error code is returned on failure. * * @access private * @see execute() */ function executeEmulateQuery($stmt, $data = false) { $p = &$this->prepare_tokens; if (!isset($this->prepare_tokens[$stmt]) || !is_array($this->prepare_tokens[$stmt]) || !sizeof($this->prepare_tokens[$stmt])) { return $this->raiseError(DB_ERROR_INVALID); } $qualquer = &$this->prepare_tokens[$stmt]; $qp = sizeof($qualquer) - 1; if ((!$data && $qp > 0) || (!is_array($data) && $qp > 1) || (is_array($data) && $qp > sizeof($data))) { $this->last_query = $this->prepared_queries[$stmt]; return $this->raiseError(DB_ERROR_NEED_MORE_DATA); } $realquery = $qualquer[0]; for ($i = 0; $i < $qp; $i++) { $type = $this->prepare_types[$stmt][$i]; if ($type == DB_PARAM_OPAQUE) { if (is_array($data)) { $fp = fopen($data[$i], 'r'); } else { $fp = fopen($data, 'r'); } $pdata = ''; if ($fp) { while (($buf = fread($fp, 4096)) != false) { $pdata .= $buf; } fclose($fp); } } else { if (is_array($data)) { $pdata = &$data[$i]; } else { $pdata = &$data; } } $realquery .= ($type != DB_PARAM_MISC) ? $this->quote($pdata) : $pdata; $realquery .= $qualquer[$i + 1]; } return $realquery; } // }}} // {{{ executeMultiple() /** * This function does several execute() calls on the same * statement handle. $data must be an array indexed numerically * from 0, one execute call is done for every "row" in the array. * * If an error occurs during execute(), executeMultiple() does not * execute the unfinished rows, but rather returns that error. * * @param resource $stmt query handle from prepare() * @param array $data numeric array containing the * data to insert into the query * * @return mixed DB_OK or DB_Error * * @access public * @see prepare(), execute() */ function executeMultiple( $stmt, &$data ) { for($i = 0; $i < sizeof( $data ); $i++) { $res = $this->execute($stmt, $data[$i]); if (DB::isError($res)) { return $res; } } return DB_OK; } // }}} // {{{ freePrepared() /* * Free the resource used in a prepared query * * @param $stmt The resurce returned by the prepare() function * @see prepare() */ function freePrepared($stmt) { // Free the internal prepared vars if (isset($this->prepare_tokens[$stmt])) { unset($this->prepare_tokens[$stmt]); unset($this->prepare_types[$stmt]); unset($this->prepared_queries[$stmt]); return true; } return false; } // }}} // {{{ modifyQuery() /** * This method is used by backends to alter queries for various * reasons. It is defined here to assure that all implementations * have this method defined. * * @param string $query query to modify * * @return the new (modified) query * * @access private */ function modifyQuery($query) { return $query; } // }}} // {{{ modifyLimitQuery() /** * This method is used by backends to alter limited queries * * @param string $query query to modify * @param integer $from the row to start to fetching * @param integer $count the numbers of rows to fetch * * @return the new (modified) query * * @access private */ function modifyLimitQuery($query, $from, $count) { return $query; } // }}} // {{{ query() /** * Send a query to the database and return any results with a * DB_result object. * * @access public * * @param string $query the SQL query or the statement to prepare * @param string $params the data to be added to the query * @return mixed a DB_result object or DB_OK on success, a DB * error on failure * * @see DB::isError * @see DB_common::prepare * @see DB_common::execute */ function &query($query, $params = array()) { if (sizeof($params) > 0) { $sth = $this->prepare($query); if (DB::isError($sth)) { return $sth; } $ret = $this->execute($sth, $params); $this->freePrepared($sth); return $ret; } else { $result = $this->simpleQuery($query); if (DB::isError($result) || $result === DB_OK) { return $result; } else { return new DB_result($this, $result); } } } // }}} // {{{ limitQuery() /** * Generates a limited query * * @param string $query query * @param integer $from the row to start to fetching * @param integer $count the numbers of rows to fetch * @param array $params required for a statement * * @return mixed a DB_Result object, DB_OK or a DB_Error * * @access public */ function &limitQuery($query, $from, $count, $params = array()) { $query = $this->modifyLimitQuery($query, $from, $count); $result = $this->query($query, $params); if (get_class($result) == 'db_result') { $result->setOption('limit_from', $from); $result->setOption('limit_count', $count); } return $result; } // }}} // {{{ getOne() /** * Fetch the first column of the first row of data returned from * a query. Takes care of doing the query and freeing the results * when finished. * * @param string $query the SQL query * @param array $params if supplied, prepare/execute will be used * with this array as execute parameters * * @return mixed DB_Error or the returned value of the query * * @access public */ function &getOne($query, $params = array()) { settype($params, "array"); if (sizeof($params) > 0) { $sth = $this->prepare($query); if (DB::isError($sth)) { return $sth; } $res = $this->execute($sth, $params); $this->freePrepared($sth); } else { $res = $this->query($query); } if (DB::isError($res)) { return $res; } $err = $res->fetchInto($row, DB_FETCHMODE_ORDERED); $res->free(); if ($err !== DB_OK) { return $err; } return $row[0]; } // }}} // {{{ getRow() /** * Fetch the first row of data returned from a query. Takes care * of doing the query and freeing the results when finished. * * @param string $query the SQL query * @param integer $fetchmode the fetch mode to use * @param array $params array if supplied, prepare/execute will be used * with this array as execute parameters * @access public * @return array the first row of results as an array indexed from * 0, or a DB error code. */ function &getRow($query, $params = null, $fetchmode = DB_FETCHMODE_DEFAULT) { // compat check, the params and fetchmode parameters used to // have the opposite order if (!is_array($params)) { if (is_array($fetchmode)) { $tmp = $params; $params = $fetchmode; $fetchmode = $tmp; } elseif ($params !== null) { $fetchmode = $params; $params = null; } } $params = (empty($params)) ? array() : $params; $fetchmode = (empty($fetchmode)) ? DB_FETCHMODE_DEFAULT : $fetchmode; settype($params, 'array'); if (sizeof($params) > 0) { $sth = $this->prepare($query); if (DB::isError($sth)) { return $sth; } $res = $this->execute($sth, $params); $this->freePrepared($sth); } else { $res = $this->query($query); } if (DB::isError($res)) { return $res; } $err = $res->fetchInto($row, $fetchmode); $res->free(); if ($err !== DB_OK) { return $err; } return $row; } // }}} // {{{ getCol() /** * Fetch a single column from a result set and return it as an * indexed array. * * @param string $query the SQL query * * @param mixed $col which column to return (integer [column number, * starting at 0] or string [column name]) * * @param array $params array if supplied, prepare/execute will be used * with this array as execute parameters * @access public * * @return array an indexed array with the data from the first * row at index 0, or a DB error code. */ function &getCol($query, $col = 0, $params = array()) { settype($params, "array"); if (sizeof($params) > 0) { $sth = $this->prepare($query); if (DB::isError($sth)) { return $sth; } $res = $this->execute($sth, $params); $this->freePrepared($sth); } else { $res = $this->query($query); } if (DB::isError($res)) { return $res; } $fetchmode = is_int($col) ? DB_FETCHMODE_ORDERED : DB_FETCHMODE_ASSOC; $ret = array(); while (is_array($row = $res->fetchRow($fetchmode))) { $ret[] = $row[$col]; } $res->free(); if (DB::isError($row)) { $ret = $row; } return $ret; } // }}} // {{{ getAssoc() /** * Fetch the entire result set of a query and return it as an * associative array using the first column as the key. * * If the result set contains more than two columns, the value * will be an array of the values from column 2-n. If the result * set contains only two columns, the returned value will be a * scalar with the value of the second column (unless forced to an * array with the $force_array parameter). A DB error code is * returned on errors. If the result set contains fewer than two * columns, a DB_ERROR_TRUNCATED error is returned. * * For example, if the table "mytable" contains: * * ID TEXT DATE * -------------------------------- * 1 'one' 944679408 * 2 'two' 944679408 * 3 'three' 944679408 * * Then the call getAssoc('SELECT id,text FROM mytable') returns: * array( * '1' => 'one', * '2' => 'two', * '3' => 'three', * ) * * ...while the call getAssoc('SELECT id,text,date FROM mytable') returns: * array( * '1' => array('one', '944679408'), * '2' => array('two', '944679408'), * '3' => array('three', '944679408') * ) * * If the more than one row occurs with the same value in the * first column, the last row overwrites all previous ones by * default. Use the $group parameter if you don't want to * overwrite like this. Example: * * getAssoc('SELECT category,id,name FROM mytable', false, null, * DB_FETCHMODE_ASSOC, true) returns: * array( * '1' => array(array('id' => '4', 'name' => 'number four'), * array('id' => '6', 'name' => 'number six') * ), * '9' => array(array('id' => '4', 'name' => 'number four'), * array('id' => '6', 'name' => 'number six') * ) * ) * * Keep in mind that database functions in PHP usually return string * values for results regardless of the database's internal type. * * @param string $query the SQL query * * @param boolean $force_array used only when the query returns * exactly two columns. If true, the values of the returned array * will be one-element arrays instead of scalars. * * @param array $params array if supplied, prepare/execute will be used * with this array as execute parameters * * @param boolean $group if true, the values of the returned array * is wrapped in another array. If the same * key value (in the first column) repeats * itself, the values will be appended to * this array instead of overwriting the * existing values. * * @access public * * @return array associative array with results from the query. */ function &getAssoc($query, $force_array = false, $params = array(), $fetchmode = DB_FETCHMODE_ORDERED, $group = false) { settype($params, "array"); if (sizeof($params) > 0) { $sth = $this->prepare($query); if (DB::isError($sth)) { return $sth; } $res = $this->execute($sth, $params); $this->freePrepared($sth); } else { $res = $this->query($query); } if (DB::isError($res)) { return $res; } $cols = $res->numCols(); if ($cols < 2) { return $this->raiseError(DB_ERROR_TRUNCATED); } $results = array(); if ($cols > 2 || $force_array) { // return array values // XXX this part can be optimized if ($fetchmode == DB_FETCHMODE_ASSOC) { while (is_array($row = $res->fetchRow(DB_FETCHMODE_ASSOC))) { reset($row); $key = current($row); unset($row[key($row)]); if ($group) { $results[$key][] = $row; } else { $results[$key] = $row; } } } else { while (is_array($row = $res->fetchRow(DB_FETCHMODE_ORDERED))) { // we shift away the first element to get // indices running from 0 again $key = array_shift($row); if ($group) { $results[$key][] = $row; } else { $results[$key] = $row; } } } if (DB::isError($row)) { $results = $row; } } else { // return scalar values while (is_array($row = $res->fetchRow(DB_FETCHMODE_ORDERED))) { if ($group) { $results[$row[0]][] = $row[1]; } else { $results[$row[0]] = $row[1]; } } if (DB::isError($row)) { $results = $row; } } $res->free(); return $results; } // }}} // {{{ getAll() /** * Fetch all the rows returned from a query. * * @param string $query the SQL query * * @param array $params array if supplied, prepare/execute will be used * with this array as execute parameters * @param integer $fetchmode the fetch mode to use * * @access public * @return array an nested array, or a DB error */ function &getAll($query, $params = null, $fetchmode = DB_FETCHMODE_DEFAULT) { // compat check, the params and fetchmode parameters used to // have the opposite order if (!is_array($params)) { if (is_array($fetchmode)) { $tmp = $params; $params = $fetchmode; $fetchmode = $tmp; } elseif ($params !== null) { $fetchmode = $params; $params = null; } } $params = (empty($params)) ? array() : $params; $fetchmode = (empty($fetchmode)) ? DB_FETCHMODE_DEFAULT : $fetchmode; settype($params, "array"); if (sizeof($params) > 0) { $sth = $this->prepare($query); if (DB::isError($sth)) { return $sth; } $res = $this->execute($sth, $params); $this->freePrepared($sth); } else { $res = $this->query($query); } if (DB::isError($res)) { return $res; } $results = array(); while (DB_OK === $res->fetchInto($row, $fetchmode)) { if ($fetchmode & DB_FETCHMODE_FLIPPED) { foreach ($row as $key => $val) { $results[$key][] = $val; } } else { $results[] = $row; } } $res->free(); if (DB::isError($row)) { return $this->raiseError($row); } return $results; } // }}} // {{{ autoCommit() /** * enable automatic Commit * * @param boolean $onoff * @return mixed DB_Error * * @access public */ function autoCommit($onoff=false) { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } // }}} // {{{ commit() /** * starts a Commit * * @return mixed DB_Error * * @access public */ function commit() { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } // }}} // {{{ rollback() /** * starts a rollback * * @return mixed DB_Error * * @access public */ function rollback() { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } // }}} // {{{ numRows() /** * returns the number of rows in a result object * * @param object DB_Result the result object to check * * @return mixed DB_Error or the number of rows * * @access public */ function numRows($result) { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } // }}} // {{{ affectedRows() /** * returns the affected rows of a query * * @return mixed DB_Error or number of rows * * @access public */ function affectedRows() { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } // }}} // {{{ errorNative() /** * returns an errormessage, provides by the database * * @return mixed DB_Error or message * * @access public */ function errorNative() { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } // }}} // {{{ nextId() /** * returns the next free id of a sequence * * @param string $seq_name name of the sequence * @param boolean $ondemand when true the seqence is * automatic created, if it * not exists * * @return mixed DB_Error or id */ function nextId($seq_name, $ondemand = true) { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } // }}} // {{{ createSequence() /** * creates a new sequence * * @param string $seq_name name of the new sequence * * @return mixed DB_Error * * @access public */ function createSequence($seq_name) { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } // }}} // {{{ dropSequence() /** * deletes a sequence * * @param string $seq_name name of the sequence * * @return mixed DB_Error * * @access public */ function dropSequence($seq_name) { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } // }}} // {{{ tableInfo() /** * returns meta data about the result set * * @param object DB_Result $result the result object to analyse * @param mixed $mode depends on implementation * * @return mixed DB_Error * * @access public */ function tableInfo($result, $mode = null) { return $this->raiseError(DB_ERROR_NOT_CAPABLE); } // }}} // {{{ getTables() /** * @deprecated */ function getTables() { return $this->getListOf('tables'); } // }}} // {{{ getListOf() /** * list internal DB info * valid values for $type are db dependent, * often: databases, users, view, functions * * @param string $type type of requested info * * @return mixed DB_Error or the requested data * * @access public */ function getListOf($type) { $sql = $this->getSpecialQuery($type); if ($sql === null) { // No support return $this->raiseError(DB_ERROR_UNSUPPORTED); } elseif (is_int($sql) || DB::isError($sql)) { // Previous error return $this->raiseError($sql); } elseif (is_array($sql)) { // Already the result return $sql; } return $this->getCol($sql); // Launch this query } // }}} // {{{ getSequenceName() function getSequenceName($sqn) { return sprintf($this->getOption("seqname_format"), preg_replace('/[^a-z0-9_]/i', '_', $sqn)); } // }}}}// Used by many driversif (!function_exists('array_change_key_case')) { define('CASE_UPPER', 1); define('CASE_LOWER', 0); function &array_change_key_case(&$array, $case) { $casefunc = ($case == CASE_LOWER) ? 'strtolower' : 'strtoupper'; $ret = array(); foreach ($array as $key => $value) { $ret[$casefunc($key)] = $value; } return $ret; }}?>e da DB/mysql.php<?php/* vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker: */// +----------------------------------------------------------------------+// | PHP Version 4 |// +----------------------------------------------------------------------+// | Copyright © 1997-2003 The PHP Group |// +----------------------------------------------------------------------+// | This source file is subject to version 2.02 of the PHP license, |// | that is bundled with this package in the file LICENSE, and is |// | available at through the world-wide-web at |// | http://www.php.net/license/2_02.txt. |// | If you did not receive a copy of the PHP license and are unable to |// | obtain it through the world-wide-web, please send a note to |// | license@php.net so we can mail you a copy immediately. |// +----------------------------------------------------------------------+// | Author: Stig Bakken <ssb@php.net> |// +----------------------------------------------------------------------+//// $Id: mysql.php,v 1.19 2003/06/21 16:45:26 cox Exp $//// Database independent query interface definition for PHP's MySQL// extension.////// XXX legend://// XXX ERRORMSG: The error message from the mysql function should// be registered here.//require_once "DB/common.php";class DB_mysql extends DB_common{ // {{{ properties var $connection; var $phptype, $dbsyntax; var $prepare_tokens = array(); var $prepare_types = array(); var $num_rows = array(); var $transaction_opcount = 0; var $autocommit = true; var $fetchmode = DB_FETCHMODE_ORDERED; /* Default fetch mode */ var $_db = false; // }}} // {{{ constructor /** * DB_mysql constructor. * * @access public */ function DB_mysql() { $this->DB_common(); $this->phptype = 'mysql'; $this->dbsyntax = 'mysql'; $this->features = array( 'prepare' => false, 'pconnect' => true, 'transactions' => true, 'limit' => 'alter' ); $this->errorcode_map = array( 1004 => DB_ERROR_CANNOT_CREATE, 1005 => DB_ERROR_CANNOT_CREATE, 1006 => DB_ERROR_CANNOT_CREATE, 1007 => DB_ERROR_ALREADY_EXISTS, 1008 => DB_ERROR_CANNOT_DROP, 1046 => DB_ERROR_NODBSELECTED, 1050 => DB_ERROR_ALREADY_EXISTS, 1051 => DB_ERROR_NOSUCHTABLE, 1054 => DB_ERROR_NOSUCHFIELD, 1062 => DB_ERROR_ALREADY_EXISTS, 1064 => DB_ERROR_SYNTAX, 1100 => DB_ERROR_NOT_LOCKED, 1136 => DB_ERROR_VALUE_COUNT_ON_ROW, 1146 => DB_ERROR_NOSUCHTABLE, 1048 => DB_ERROR_CONSTRAINT, ); } // }}} // {{{ connect() /** * Connect to a database and log in as the specified user. * * @param $dsn the data source name (see DB::parseDSN for syntax) * @param $persistent (optional) whether the connection should * be persistent * @access public * @return int DB_OK on success, a DB error on failure */ function connect($dsninfo, $persistent = false) { if (!DB::assertExtension('mysql')) return $this->raiseError(DB_ERROR_EXTENSION_NOT_FOUND); $this->dsn = $dsninfo; if (isset($dsninfo['protocol]) && $dsninfo['protocol'] == 'unix') { $dbhost = ':' . $dsninfo['socket']; } else { $dbhost = $dsninfo['hostspec'] ? $dsninfo['hostspec'] : 'localhost'; if (!empty($dsninfo['port'])) { $dbhost .= ':' . $dsninfo['port']; } } $user = $dsninfo['username']; $pw = $dsninfo['password']; $connect_function = $persistent ? 'mysql_pconnect' : 'mysql_connect'; if ($dbhost && $user && $pw) { $conn = @$connect_function($dbhost, $user, $pw); } elseif ($dbhost && $user) { $conn = @$connect_function($dbhost, $user); } elseif ($dbhost) { $conn = @$connect_function($dbhost); } else { $conn = false; } if (empty($conn)) { if (($err = @mysql_error()) != '') { return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, $err); } elseif (empty($php_errormsg)) { return $this->raiseError(DB_ERROR_CONNECT_FAILED); } else { return $this->raiseError(DB_ERROR_CONNECT_FAILED, null, null, null, $php_errormsg); } } if ($dsninfo['database']) { if (!@mysql_select_db($dsninfo['database'], $conn)) { switch(mysql_errno($conn)) { case 1049: return $this->raiseError(DB_ERROR_NOSUCHDB, null, null, null, mysql_error($conn)); break; case 1044: return $this->raiseError(DB_ERROR_ACCESS_VIOLATION, null, null, null, mysql_error($conn)); break; default: return $this->raiseError(DB_ERROR, null, null, null, mysql_error($conn)); break; } } // fix to allow calls to different databases in the same script $this->_db = $dsninfo['database']; } $this->connection = $conn; return DB_OK; } // }}} // {{{ disconnect() /** * Log out and disconnect from the database. * * @access public * * @return bool TRUE on success, FALSE if not connected. */ function disconnect() { $ret = mysql_close($this->connection); $this->connection = null; return $ret; } // }}} // {{{ simpleQuery() /** * Send a query to MySQL and return the results as a MySQL resource * identifier. * * @param the SQL query * * @access public * * @return mixed returns a valid MySQL result for successful SELECT * queries, DB_OK for other successful queries. A DB error is * returned on failure. */ function simpleQuery($query) { $ismanip = DB::isManip($query); $this->last_query = $query; $query = $this->modifyQuery($query); if ($this->_db) { if (!@mysql_select_db($this->_db, $this->connection)) { return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED); } } if (!$this->autocommit && $ismanip) { if ($this->transaction_opcount == 0) { $result = @mysql_query('SET AUTOCOMMIT=0', $this->connection); $result = @mysql_query('BEGIN', $this->connection); if (!$result) { return $this->mysqlRaiseError(); } } $this->transaction_opcount++; } $result = @mysql_query($query, $this->connection); if (!$result) { return $this->mysqlRaiseError(); } if (is_resource($result)) { $numrows = $this->numrows($result); if (is_object($numrows)) { return $numrows; } $this->num_rows[$result] = $numrows; return $result; } return DB_OK; } // }}} // {{{ nextResult() /** * Move the internal mysql result pointer to the next available result * * This method has not been implemented yet. * * @param a valid sql result resource * * @access public * * @return false */ function nextResult($result) { return false; } // }}} // {{{ fetchInto() /** * Fetch a row and insert the data into an existing array. * * @param $result MySQL result identifier * @param $arr (reference) array where data from the row is stored * @param $fetchmode how the array data should be indexed * @param $rownum the row number to fetch * @access public * * @return int DB_OK on success, a DB error on failure */ function fetchInto($result, &$arr, $fetchmode, $rownum=null) { /*if ($rownum !== null) { if (!@mysql_data_seek($result, $rownum)) { return null; } }*/ if ($fetchmode & DB_FETCHMODE_ASSOC) { $arr = @mysql_fetch_array($result, MYSQL_ASSOC); } else { $arr = @mysql_fetch_row($result); } if (!$arr) { // See: http://bugs.php.net/bug.php?id=22328 // for why we can't check errors on fetching return null; /* $errno = @mysql_errno($this->connection); if (!$errno) { return NULL; } return $this->mysqlRaiseError($errno); */ } return DB_OK; } // }}} // {{{ freeResult() /** * Free the internal resources associated with $result. * * @param $result MySQL result identifier or DB statement identifier * * @access public * * @return bool TRUE on success, FALSE if $result is invalid */ function freeResult($result) { if (is_resource($result)) { return mysql_free_result($result); } $result = (int)$result; // $result is a prepared query handle if (!isset($this->prepare_tokens[$result])) { return false; } // I fixed the unset thing. $this->prepare_types = array(); $this->prepare_tokens = array(); return true; } // }}} // {{{ numCols() /** * Get the number of columns in a result set. * * @param $result MySQL result identifier * * @access public * * @return int the number of columns per row in $result */ function numCols($result) { $cols = @mysql_num_fields($result); if (!$cols) { return $this->mysqlRaiseError(); } return $cols; } // }}} // {{{ numRows() /** * Get the number of rows in a result set. * * @param $result MySQL result identifier * * @access public * * @return int the number of rows in $result */ function numRows($result) { $rows = @mysql_num_rows($result); if ($rows === null) { return $this->mysqlRaiseError(); } return $rows; } // }}} // {{{ autoCommit() /** * Enable/disable automatic commits */ function autoCommit($onoff = false) { // XXX if $this->transaction_opcount > 0, we should probably // issue a warning here. $this->autocommit = $onoff ? true : false; return DB_OK; } // }}} // {{{ commit() /** * Commit the current transaction. */ function commit() { if ($this->transaction_opcount > 0) { if ($this->_db) { if (!@mysql_select_db($this->_db, $this->connection)) { return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED); } } $result = @mysql_query('COMMIT', $this->connection); $result = @mysql_query('SET AUTOCOMMIT=1', $this->connection); $this->transaction_opcount = 0; if (!$result) { return $this->mysqlRaiseError(); } } return DB_OK; } // }}} // {{{ rollback() /** * Roll back (undo) the current transaction. */ function rollback() { if ($this->transaction_opcount > 0) { if ($this->_db) { if (!@mysql_select_db($this->_db, $this->connection)) { return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED); } } $result = @mysql_query('ROLLBACK', $this->connection); $result = @mysql_query('SET AUTOCOMMIT=1', $this->connection); $this->transaction_opcount = 0; if (!$result) { return $this->mysqlRaiseError(); } } return DB_OK; } // }}} // {{{ affectedRows() /** * Gets the number of rows affected by the data manipulation * query. For other queries, this function returns 0. * * @return number of rows affected by the last query */ function affectedRows() { if (DB::isManip($this->last_query)) { $result = @mysql_affected_rows($this->connection); } else { $result = 0; } return $result; } // }}} // {{{ errorNative() /** * Get the native error code of the last error (if any) that * occured on the current connection. * * @access public * * @return int native MySQL error code */ function errorNative() { return mysql_errno($this->connection); } // }}} // {{{ nextId() /** * Get the next value in a sequence. We emulate sequences * for MySQL. Will create the sequence if it does not exist. * * @access public * * @param string $seq_name the name of the sequence * * @param bool $ondemand whether to create the sequence table on demand * (default is true) * * @return mixed a sequence integer, or a DB error */ function nextId($seq_name, $ondemand = true) { $seqname = $this->getSequenceName($seq_name); do { $repeat = 0; $this->pushErrorHandling(PEAR_ERROR_RETURN); $result = $this->query("UPDATE ${seqname} ". 'SET id=LAST_INSERT_ID(id+1)'); $this->popErrorHandling(); if ($result == DB_OK) { /** COMMON CASE **/ $id = mysql_insert_id($this->connection); if ($id != 0) { return $id; } /** EMPTY SEQ TABLE **/ // Sequence table must be empty for some reason, so fill it and return 1 // Obtain a user-level lock $result = $this->getOne("SELECT GET_LOCK('${seqname}_lock',10)"); if (DB::isError($result)) { return $this->raiseError($result); } if ($result == 0) { // Failed to get the lock, bail with a DB_ERROR_NOT_LOCKED error return $this->mysqlRaiseError(DB_ERROR_NOT_LOCKED); } // add the default value $result = $this->query("REPLACE INTO ${seqname} VALUES (0)"); if (DB::isError($result)) { return $this->raiseError($result); } // Release the lock $result = $this->getOne("SELECT RELEASE_LOCK('${seqname}_lock')"); if (DB::isError($result)) { return $this->raiseError($result); } // We know what the result will be, so no need to try again return 1; /** ONDEMAND TABLE CREATION **/ } elseif ($ondemand && DB::isError($result) && $result->getCode() == DB_ERROR_NOSUCHTABLE) { $result = $this->createSequence($seq_name); if (DB::isError($result)) { return $this->raiseError($result); } else { $repeat = 1; } /** BACKWARDS COMPAT **/ } elseif (DB::isError($result) && $result->getCode() == DB_ERROR_ALREADY_EXISTS) { // see _BCsequence() comment $result = $this->_BCsequence($seqname); if (DB::isError($result)) { return $this->raiseError($result); } $repeat = 1; } } while ($repeat); return $this->raiseError($result); } // }}} // {{{ createSequence() function createSequence($seq_name) { $seqname = $this->getSequenceName($seq_name); $res = $this->query("CREATE TABLE ${seqname} ". '(id INTEGER UNSIGNED AUTO_INCREMENT NOT NULL,'. ' PRIMARY KEY(id))'); if (DB::isError($res)) { return $res; } // insert yields value 1, nextId call will generate ID 2 $res = $this->query("INSERT INTO ${seqname} VALUES(0)"); if (DB::isError($res)) { return $res; } // so reset to zero return $this->query("UPDATE ${seqname} SET id = 0;"); } // }}} // {{{ dropSequence() function dropSequence($seq_name) { $seqname = $this->getSequenceName($seq_name); return $this->query("DROP TABLE ${seqname}"); } // }}} // {{{ _BCsequence() /** * Backwards compatibility with old sequence emulation implementation * (clean up the dupes) * * @param string $seqname The sequence name to clean up * @return mixed DB_Error or true */ function _BCsequence($seqname) { // Obtain a user-level lock... this will release any previous // application locks, but unlike LOCK TABLES, it does not abort // the current transaction and is much less frequently used. $result = $this->getOne("SELECT GET_LOCK('${seqname}_lock',10)"); if (DB::isError($result)) { return $result; } if ($result == 0) { // Failed to get the lock, can't do the conversion, bail // with a DB_ERROR_NOT_LOCKED error return $this->mysqlRaiseError(DB_ERROR_NOT_LOCKED); } $highest_id = $this->getOne("SELECT MAX(id) FROM ${seqname}"); if (DB::isError($highest_id)) { return $highest_id; } // This should kill all rows except the highest // We should probably do something if $highest_id isn't // numeric, but I'm at a loss as how to handle that... $result = $this->query("DELETE FROM ${seqname} WHERE id <> $highest_id"); if (DB::isError($result)) { return $result; } // If another thread has been waiting for this lock, // it will go thru the above procedure, but will have no // real effect $result = $this->getOne("SELECT RELEASE_LOCK('${seqname}_lock')"); if (DB::isError($result)) { return $result; } return true; } // }}} // {{{ quote() /** * Quote the given string so it can be safely used within string delimiters * in a query. * @param $string mixed Data to be quoted * @return mixed "NULL" string, quoted string or original data */ function quote($str = null) { switch (strtolower(gettype($str))) { case 'null': return 'NULL'; case 'integer': case 'double': return $str; case 'string': default: if(function_exists('mysql_real_escape_string')) { return "'".mysql_real_escape_string($str, $this->connection)."'"; } else { return "'".mysql_escape_string($str)."'"; } } } // }}} // {{{ modifyQuery() function modifyQuery($query, $subject = null) { if ($this->options['optimize] == 'portability') { // "DELETE FROM table" gives 0 affected rows in MySQL. // This little hack lets you know how many rows were deleted. if (preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $query)) { $query = preg_replace('/^\s*DELETE\s+FROM\s+(\S+)\s*$/', 'DELETE FROM \1 WHERE 1=1', $query); } } return $query; } // }}} // {{{ modifyLimitQuery() function modifyLimitQuery($query, $from, $count) { if (DB::isManip($query)) { return $query . " LIMIT $count"; } else { return $query . " LIMIT $from, $count"; } } // }}} // {{{ mysqlRaiseError() function mysqlRaiseError($errno = null) { if ($errno === null) { $errno = $this->errorCode(mysql_errno($this->connection)); } return $this->raiseError($errno, null, null, null, @mysql_errno($this->connection) . " ** " . @mysql_error($this->connection)); } // }}} // {{{ tableInfo() function tableInfo($result, $mode = null) { $count = 0; $id = 0; $res = array(); /* * depending on $mode, metadata returns the following values: * * - mode is null (default): * $result[]: * [0]["table"] table name * [0]["name"] field name * [0]["type"] field type * [0]["len"] field length * [0]["flags"] field flags * * - mode is DB_TABLEINFO_ORDER * $result[]: * ["num_fields"] number of metadata records * [0]["table"] table name * [0]["name"] field name * [0]["type"] field type * [0]["len"] field length * [0]["flags"] field flags * ["order"][field name] index of field named "field name" * The last one is used, if you have a field name, but no index. * Test: if (isset($result['meta']['myfield'])) { ... * * - mode is DB_TABLEINFO_ORDERTABLE * the same as above. but additionally * ["ordertable"][table name][field name] index of field * named "field name" * * this is, because if you have fields from different * tables with the same field name * they override each * other with DB_TABLEINFO_ORDER * * you can combine DB_TABLEINFO_ORDER and * DB_TABLEINFO_ORDERTABLE with DB_TABLEINFO_ORDER | * DB_TABLEINFO_ORDERTABLE * or with DB_TABLEINFO_FULL */ // if $result is a string, then we want information about a // table without a resultset if (is_string($result)) { $id = @mysql_list_fields($this->dsn['database'], $result, $this->connection); if (empty($id)) { return $this->mysqlRaiseError(); } } else { // else we want information about a resultset $id = $result; if (empty($id)) { return $this->mysqlRaiseError(); } } $count = @mysql_num_fields($id); // made this IF due to performance (one if is faster than $count if's) if (empty($mode)) { for ($i=0; $i<$count; $i++) { $res[$i]['table'] = @mysql_field_table ($id, $i); $res[$i]['name'] = @mysql_field_name ($id, $i); $res[$i]['type'] = @mysql_field_type ($id, $i); $res[$i]['len'] = @mysql_field_len ($id, $i); $res[$i]['flags'] = @mysql_field_flags ($id, $i); } } else { // full $res['num_fields']= $count; for ($i=0; $i<$count; $i++) { $res[$i]['table'] = @mysql_field_table ($id, $i); $res[$i]['name'] = @mysql_field_name ($id, $i); $res[$i]['type'] = @mysql_field_type ($id, $i); $res[$i]['len'] = @mysql_field_len ($id, $i); $res[$i]['flags'] = @mysql_field_flags ($id, $i); if ($mode & DB_TABLEINFO_ORDER) { $res['order'][$res[$i]['name']] = $i; } if ($mode & DB_TABLEINFO_ORDERTABLE) { $res['ordertable'][$res[$i]['table']][$res[$i]['name']] = $i; } } } // free the result only if we were called on a table if (is_string($result)) { @mysql_free_result($id); } return $res; } // }}} // {{{ getSpecialQuery() /** * Returns the query needed to get some backend info * @param string $type What kind of info you want to retrieve * @return string The SQL query string */ function getSpecialQuery($type) { switch ($type) { case 'tables': $sql = "SHOW TABLES"; break; case 'views': return DB_ERROR_NOT_CAPABLE; case 'users': $sql = "select distinct User from user"; if($this->dsn['database'] != 'mysql') { $dsn = $this->dsn; $dsn['database'] = 'mysql'; if (DB::isError($db = DB::connect($dsn))) { return $db; } $sql = $db->getCol($sql); $db->disconnect(); // XXX Fixme the mysql driver should take care of this if (!@mysql_select_db($this->dsn['database'], $this->connection)) { return $this->mysqlRaiseError(DB_ERROR_NODBSELECTED); } } return $sql; break; case 'databases': $sql = "SHOW DATABASES"; break; default: return null; } return $sql; } // }}} // TODO/wishlist: // longReadlen // binmode}?> Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 cassianooliver Postado Novembro 20, 2008 Denunciar Share Postado Novembro 20, 2008 não seria melhor indicar as linhas onde ele acusa o erro??? Citar Link para o comentário Compartilhar em outros sites More sharing options...
0 kaioh. Postado Novembro 20, 2008 Autor Denunciar Share Postado Novembro 20, 2008 Notice: Only variable references should be returned by reference in /home/portugal/public_html/top/DB/common.php on line 298Notice: Only variable references should be returned by reference in /home/portugal/public_html/top/DB/common.php on line 766Notice: Object of class DB_Error could not be converted to int in /home/portugal/public_html/top/DB/mysql.php on line 312Notice: Only variable references should be returned by reference in /home/portugal/public_html/top/DB/common.php on line 766Notice: Only variable references should be returned by reference in /home/portugal/public_html/top/DB/common.php on line 766Notice: Only variable references should be returned by reference in /home/portugal/public_html/top/DB/common.php on line 766Notice: Only variable references should be returned by reference in /home/portugal/public_html/top/DB/common.php on line 766Notice: Only variable references should be returned by reference in /home/portugal/public_html/top/DB/common.php on line 766Notice: Only variable references should be returned by reference in /home/portugal/public_html/top/DB/common.php on line 766Notice: Only variable references should be returned by reference in /home/portugal/public_html/top/DB/common.php on line 766Notice: Only variable references should be returned by reference in /home/portugal/public_html/top/DB/common.php on line 766 Citar Link para o comentário Compartilhar em outros sites More sharing options...
Pergunta
kaioh.
Olá , Galerinha
Eu e um amigo meu estamos desenvolvendo um top30 tipo top30 , peguei um script pronto o poblema é que ele não ta aparecendo os sites aonde devia aparecer o unico erro do script alguém pode nos ajudar?
www.portugalpet.com.br/top
Link para o comentário
Compartilhar em outros sites
6 respostass a esta questão
Posts Recomendados
Participe da discussão
Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.