Ejemplo n.º 1
0
//--------------------------------------------------------------------------
string Connection::info ()
{
  char *i = mysql_info(&mysql);
  if (!i)
    return string();
  else
    return string(i);
}
Ejemplo n.º 2
0
static PyObject* wsql_connection_get_info(wsql_connection *self, void* closure)
{
    const char *s;
    CHECK_CONNECTION(self, NULL);
    s = mysql_info(&(self->connection));
    if (s)
        return PyString_FromString(s);
    Py_RETURN_NONE;
}
Ejemplo n.º 3
0
static JSVAL info(JSARGS args) {
	HandleScope scope;
	MYSQL *handle = (MYSQL *) args[0]->IntegerValue();
	const char *info = mysql_info(handle);
	if (info) {
		return scope.Close(String::New(info));
	}
	else {
		return scope.Close(Null());
	}
}
Ejemplo n.º 4
0
static VALUE rb_mysql_info(VALUE self) {
  const char *info;
  VALUE rb_str;
  GET_CLIENT(self);

  info = mysql_info(wrapper->client);

  if (info == NULL) {
    return Qnil;
  }

  rb_str = rb_str_new2(info);
#ifdef HAVE_RUBY_ENCODING_H
  rb_enc_associate(rb_str, rb_utf8_encoding());
#endif

  return rb_str;
}
Ejemplo n.º 5
0
int CToolKit::GetUpdateNum(MYSQL *pMysql)
{
        int nMatch = 0;
        const char *pInfo = mysql_info(pMysql);
        if (pInfo != NULL)
        {                 
                char pTmp[] = "Rows matched:";
                char *pMatch = (char*)strstr(pInfo, pTmp);
                char *pChange = (char*)strstr(pInfo, "Changed");
                if (pMatch != NULL && pChange != NULL)
                {
                        unsigned int tmpLen  =  strlen(pTmp);
                        char *pBegin = pMatch + tmpLen;
                        int nLen = pChange - pMatch - tmpLen;
                        char tmpMatch[40] = {0};
                        if (nLen < 40)
                        memcpy(tmpMatch, pBegin, nLen);
                        nMatch = atoi(tmpMatch);
                }
        }
        return nMatch;
}
Ejemplo n.º 6
0
const char *GetExecuteSqlResultInfor(MYSQL *pMySql)
{
	return mysql_info(pMySql);
}
Ejemplo n.º 7
0
	const char* info()			{ return mysql_info( pMysql_ ); }
Ejemplo n.º 8
0
/// 取得更新信息
/// \return 返回更新信息
string MysqlClient::info() {
	if ( _connected )
		return string( mysql_info(&_mysql) );
	else
		return string( "" );
}
Ejemplo n.º 9
0
bool CMySQLQuery::execRealQuery(const char * qry, ulong len)
{
#ifdef DEBUG
  qDebug("CMySQLQuery::execRealQuery()");
#endif
  
  check_pending_event = 0;
  cancel_execution = false;
  freeResult();
  returned_results = false;
  QString c = QString::null;
  if (!m_mysql->connectionName().isEmpty())
    c = "[" + m_mysql->connectionName() + "] ";
  emit m_mysql->sqldebug(m_mysql->codec()->fromUnicode(c + qry));
  if (!m_mysql->isConnected())
  {
    if (emiterror)
      m_mysql->emitError();
    return false;
  }  
  
  QTime tm;
  tm.start();

#ifdef QT_THREAD_SUPPORT
  QueryThread queryThread(m_mysql->mysql, qry, len);
  queryThread.start();
  queryThread.wait();
  if (!queryThread.getResult())
  {    
    if (emiterror)
      m_mysql->emitError();
    return false;
  }
#else
  if (mysql_real_query(m_mysql->mysql, qry, len) != 0)
  {
    if (emiterror)
      m_mysql->emitError();
    return false;
  }
#endif

  if (!(mysql_res=mysql_store_result(m_mysql->mysql)))
  {
    mysql_res = NULL;
    if (mysql_error(m_mysql->mysql)[0])
    {
      if (emiterror)
        m_mysql->emitError();
      return false;
    }
  }
  last_query = qry;
  if (mysql_res)
  {
    mysql_fields = mysql_fetch_fields(mysql_res);
    num_fields = mysql_num_fields(mysql_res);
    returned_results = true;
  }
  else
  {
    mysql_fields = 0;
    num_fields = 0;
  }
 
  if (emitmessages)
  {
    QString time_buff = " (" + QString::number((double)tm.elapsed() / 1000L, 'f', 2) + ") " + tr("sec");
    QString buff;
    uint flag;
    if (mysql_res)
    {
      flag = INFORMATION;
      if (!mysql_num_rows(mysql_res))
        buff = tr("Empty set");
      else
      {
        buff = QString::number(numRows()) + " ";
        buff += numRows() == 1 ? tr("row") : tr("rows");
        buff += " " + tr("in set");
      }
    }
    else
    {
      flag = WARNING;
      if (mysql_affected_rows(m_mysql->mysql) == ~(ulong) 0)
        buff = tr("Query OK");
      else
      {
        buff = tr("Query OK,") + " ";
        buff += QString::number((ulong) mysql_affected_rows(m_mysql->mysql)) + " ";
        buff += mysql_affected_rows(m_mysql->mysql) == 1 ? tr("row") : tr("rows");
        buff += " " + tr("affected");
      }
    }
    buff += time_buff;
    m_mysql->emitMessage(flag, buff);
    if (mysql_info(m_mysql->mysql))
      m_mysql->emitMessage(INFORMATION, mysql_info(m_mysql->mysql));
  }

  return true;
}
Ejemplo n.º 10
0
/*	info()		*/
static VALUE info(VALUE obj)
{
    const char* p = mysql_info(GetHandler(obj));
    return p? rb_tainted_str_new2(p): Qnil;
}
Ejemplo n.º 11
0
Variant HHVM_FUNCTION(mysql_info,
                      const Variant& link_identifier /* = uninit_null() */) {
  MYSQL *conn = MySQL::GetConn(link_identifier);
  if (!conn) return false;
  return String(mysql_info(conn), CopyString);
}
Ejemplo n.º 12
0
GString			GSqlDatabase::GetLastInformation(void)
{
	return (mysql_info(&(this->_mysql)));
}
Ejemplo n.º 13
0
char const* Connection::GetStatementInfo()
{
    return mysql_info(MySQL);
}
Ejemplo n.º 14
0
// const char *mysql_info(MYSQL *mysql)
static IDL_VPTR IDL_mg_mysql_info(int argc, IDL_VPTR *argv) {
    const char *info = mysql_info((MYSQL *)argv[0]->value.ptrint);
    return IDL_StrToSTRING(info);
}
Ejemplo n.º 15
0
DDatabaseResult & DMySQL::exec ( const DString & query )
{
	MYSQL_RES *results;
	MYSQL_FIELD *fields;
	MYSQL_ROW row;
	m_result.clear();
	int errnb;
	uint num_fields;
	unsigned long *lengths;
	DDatabaseRow row_result;
	my_ulonglong llu;
	DString buffer;
	bool closeConnection = false;
	long int old_errnb;

	m_result.clear();

	// If connection was not initialized, try to open it
	if ( !m_opened || m_mysql == 0 )
	{
		closeConnection = true;
		open();
		// If connection was not initialized, quit
		if ( !m_opened || m_mysql == 0 )
		{
			m_result.errnb = NOT_CONNECTED;
			m_result.error = _errors[NOT_CONNECTED];
#ifdef WITH_EXCEPTIONS
			if ( m_use_dexceptions )
			{
				throw DEXCEPTION_DB ( m_result.error, m_result.errnb );
			}
#endif
			return this->m_result;
		}
	}
	m_result.last_query = query;

	// If connection was lose, exit
	errnb = mysql_ping ( m_mysql );
	if ( errnb )
	{
		m_result.errnb = CONNECTION_LOSE;
		m_result.error = _errors[CONNECTION_LOSE];
#ifdef WITH_EXCEPTIONS
		if ( m_use_dexceptions )
		{
			throw DEXCEPTION_DB ( m_result.error, m_result.errnb );
		}
#endif
		return this->m_result;
	}

	// execute query
	errnb = mysql_real_query ( m_mysql, query.c_str(), query.length() );

	if ( errnb ) // if query was not executed
	{
		m_result.errnb = QUERY_ERROR;
		m_result.error = mysql_error ( m_mysql );
#ifdef WITH_EXCEPTIONS
		if ( m_use_dexceptions )
		{
			throw DEXCEPTION_DB ( m_result.error, m_result.errnb );
		}
#endif
		return this->m_result;
	}
	// Get the last AUTO_INCREMENT
	llu = mysql_insert_id ( m_mysql );
	m_result.last_auto_increment = static_cast<long long unsigned int> ( llu );

	// Get the number of affected rows
	llu = mysql_affected_rows ( m_mysql );
	if ( llu != static_cast<my_ulonglong>(-1) )
	{
		m_result.affected_row = static_cast<long long unsigned int> ( llu );
	}

	// Get info
	// We must pass via a const char * because the pointer can be null
	// (in case of not infos are available).
	const char* str = mysql_info ( m_mysql );
	if ( str )
	{
		m_result.info = str;
	}
	else
	{
		m_result.info = "";
	}

	// Get the number of fields
	num_fields = mysql_field_count ( m_mysql );

	// Get results of query if any
	results = mysql_store_result ( m_mysql );
	if ( results )
	{
		// Get field names
		fields = mysql_fetch_fields ( results );
		while ( ( row = mysql_fetch_row ( results ) ) )
		{
			// Get the length of data by index
			lengths = mysql_fetch_lengths ( results );
			for ( unsigned int i = 0 ; i < num_fields ; i++ )
			{
				if ( lengths[i] == 0 )
				{
					buffer = "NULL";
				}
				else
				{
					buffer = row[i];
				}
				// Affect data to field name
				row_result[fields[i].name] = buffer;
			}
			m_result.rows.push_back ( row_result );
		}
		// free the result memory
		mysql_free_result ( results );
		m_result.errnb = SUCCESS;
	}
	else
	{
		if ( num_fields > 0 )
		{
			m_result.errnb = UNKNOW_ERROR;
			m_result.error = mysql_error ( m_mysql );
		}
		else
		{
			m_result.errnb = SUCCESS;
		}
	}

	if ( closeConnection )
	{
		old_errnb = m_result.errnb;
		close();
		m_result.errnb = old_errnb;
	}

	return this->m_result;
}
Ejemplo n.º 16
0
Variant f_mysql_info(CVarRef link_identifier /* = uninit_null() */) {
  MYSQL *conn = MySQL::GetConn(link_identifier);
  if (!conn) return false;
  return String(mysql_info(conn), CopyString);
}
Ejemplo n.º 17
0
string CDatabase_Connection::info()
{
	return mysql_info(&my);
}