Page 1 of 1

MySQL_query problem?

Posted: Tue Mar 20, 2012 4:32 am
by jayson.ph
Hi all.

can i have a favor to help to recognized the problem below. i was stop from this in just 1 week for this error,

Code: Select all

public function	ExecuteS($query, $array = true, $use_cache = 1)
	{
		$this->_result = false;
		$this->_lastQuery = $query;
		if ($use_cache AND _PS_CACHE_ENABLED_)
			if ($array AND ($result = Cache::getInstance()->get(md5($query))))
			{
				$this->_lastCached = true;
				return $result;
			}
>>>>>>>>>>>>>>>		if ($this->_link && $this->_result = mysql_query($query, $this->_link))[/color]
		{
			$this->_lastCached = false;
			if (_PS_DEBUG_SQL_)
				$this->displayMySQLError($query);
			if (!$array)
				return $this->_result;
			$resultArray = array();
			// Only SELECT queries and a few others return a valid resource usable with mysql_fetch_assoc
			if ($this->_result !== true)
				while ($row = mysql_fetch_assoc($this->_result))
					$resultArray[] = $row;
			if ($use_cache AND _PS_CACHE_ENABLED_)	
				Cache::getInstance()->setQuery($query, $resultArray);
			return $resultArray;
		}
		if (_PS_DEBUG_SQL_)
			$this->displayMySQLError($query);
		return false;
	}

	public function nextRow($result = false)
	{
		return mysql_fetch_assoc($result ? $result : $this->_result);
	}
	
	public function	delete($table, $where = false, $limit = false, $use_cache = 1)
	{
		$this->_result = false;
		if ($this->_link)
		{
			$query  = 'DELETE FROM `'.pSQL($table).'`'.($where ? ' WHERE '.$where : '').($limit ? ' LIMIT '.(int)($limit) : '');
			$res =  mysql_query($query, $this->_link);
			if ($use_cache AND _PS_CACHE_ENABLED_)
				Cache::getInstance()->deleteQuery($query);
			return $res;
		}
			
		return false;
	}
	
	public function	NumRows()
	{
		if (!$this->_lastCached AND $this->_link AND $this->_result)
		{
			$nrows = mysql_num_rows($this->_result);
			if (_PS_CACHE_ENABLED_)
				Cache::getInstance()->setNumRows(md5($this->_lastQuery), $nrows);
			return $nrows;
		}
		elseif (_PS_CACHE_ENABLED_ AND $this->_lastCached)
		{
			return Cache::getInstance()->getNumRows(md5($this->_lastQuery));
		}
	}
	
	public function	Insert_ID()
	{
		if ($this->_link)
			return mysql_insert_id($this->_link);
		return false;
	}
	
	public function	Affected_Rows()
	{
		if ($this->_link)
			return mysql_affected_rows($this->_link);
		return false;
	}

	protected function q($query, $use_cache = 1)
	{
		global $webservice_call;
		$this->_result = false;
		if ($this->_link)
		{
			$result =  mysql_query($query, $this->_link);
			$this->_lastQuery = $query;
			if ($webservice_call)
				$this->displayMySQLError($query);
			if ($use_cache AND _PS_CACHE_ENABLED_)
				Cache::getInstance()->deleteQuery($query);
			return $result;
		}
		return false;
	}
	
here is the error message, : Warning: mysql_query() [function.mysql-query]: Unable to save result set in /home/octagon/public_html/classes/MySQL.php on line 145.

Thank very much.

Re: MySQL_query problem?

Posted: Tue Mar 20, 2012 5:07 am
by requinix
Some quick Googling (I suggest you try it) mentions possible corruption with MySQL data files.

From a command line try running

Code: Select all

$ myisamchk -r /var/lib/mysql/database/*.MYI
replacing /var/lib/mysql with the path to your MySQL's data files.

Re: MySQL_query problem?

Posted: Tue Mar 20, 2012 5:34 am
by jayson.ph
How ? and where i can put the code/ file path ?

Re: MySQL_query problem?

Posted: Tue Mar 20, 2012 6:00 am
by requinix
Who maintains your database?

Re: MySQL_query problem?

Posted: Tue Mar 20, 2012 10:08 am
by jayson.ph
actually, i am the admin but. ah, i am new for this.. i mean, im not familiar the tool they use, they use prestashop". an for now im lost and moving to keep familiar... the is octagon.com.ph, please take a look, there are a lot problem.

Thanks

Re: MySQL_query problem?

Posted: Tue Mar 20, 2012 10:12 am
by theserve
you need to logon to the command line via ssh to run myisamchk. That is of course if your database is using the MyISAM storage engine.

Re: MySQL_query problem?

Posted: Tue Mar 20, 2012 10:20 am
by jayson.ph
God im bleeding here.. and how do i find the command line for the ssh?