: 시간의 커플 이제 확인을 나는 페이지를 새로 고침데이터베이스 난 그냥 약 백명 매일 얻는 사이트가 있지만 사용자로 로그인이 오류 메시지가있어 오류
Warning: mysqli::mysqli() [mysqli.mysqli]: (42000/1203): User mexautos_Juan already has more than 'max_user_connections' active connections in /home/mexautos/public_html/kiubbo/data/model.php on line 26
Warning: mysqli::query() [mysqli.query]: Couldn't fetch mysqli in /home/mexautos/public_html/kiubbo/data/model.php on line 87
Query failed
을하지만, 이후로 나는 많은 사람들이 내 코드에서 오류를 의심하지 않는다. 어디에서 찾아야 하는가?
들으
편집 : 데이터베이스 연결을 처리하는 것 코드에서
<?php
/*
Model is the base class from which the other
model classes will be derived. It offers basic
functionality to access databases
*/
require_once($_SERVER['DOCUMENT_ROOT'].'/config.php');
require_once(SITE_ROOT.'includes/exceptions.php');
class Model {
private $created;
private $modified;
static function getConnection()
{
/*
Connect to the database and return a
connection or null on failure
*/
$db = new mysqli (DB_HOST, DB_USER, DB_PASS, DB_NAME);
if(!$db) {
echo mysql_error();
throw new Exception('Could not connect to database', EX_NO_DATABASE_CONNECTION);
}
return $db;
}
static function execSQL($query)
{
/*
Execute a SQL query on the database
passing the tablename and the sql query.
Returns the resultset
*/
$db = null;
$results = null;
//echo "query is $query";
try
{
$db = Model::getConnection();
$results = $db->query($query);
if(!$results) {
throw new Exception('Query failed', EX_QUERY_FAILED);
}
}
catch(Exception $e)
{
/* errors are handled higher in the
object hierarchy
*/
throw $e;
}
Model::closeConnection($db);
return $results;
}
static function execSQl2($query)
{
/*
Execute a SQL query on the database
passing the tablename and the sql query.
Returns the LAST_INSERT_ID
*/
$db = null;
$lastid = null;
//echo "query is $query";
try
{
$db = Model::getConnection();
$results = $db->query($query);
if(!$results) {
throw new Exception('Query failed', EX_QUERY_FAILED);
}
$lastid = $db->insert_id;
}
catch(Exception $e)
{
/* errors are handled higher in the
object hierarchy
*/
throw $e;
}
Model::closeConnection($db);
return $lastid;
}
function delete($table, $id, $conditions = '')
{
$query = "delete from $table where id = $id";
try
{
$db = Model::getConnection();
$results = Model::execSQL($query);
if(!$results){
throw new Exception('Could not delete this object', EX_DELETE_ERROR);
}
return $results->num_rows;
}
catch(Exception $e)
{
throw $e;
}
}
static function closeConnection($db)
{
$db->close();
}
function getCreated()
{
return $this->created;
}
function setCreated($value)
{
$this->created = $value;
}
function getModified()
{
return $this->modified;
}
function setModified($value)
{
$this->modified = $value;
}
}
?>
감사합니다. 그렇다면 기본적으로 $ db와 동일한 작업을 수행해야합니까? 다음 함수를 사용하여 다른 함수를 작성하십시오. $ results-> close(); ? – jcslzr
솔직히, 나는 잘 모르겠다. 내 의견을 삭제했는데, 이는 내 마음에 들지 않았다. 그러나 mysqli에 대한 문서를 살펴보면 쿼리 결과 집합이 데이터베이스에 대한 버퍼링 된 연결이라는 것을 강하게 알 수 있습니다. $ db-> close()가 연결을 종료하는 것처럼 보일 때까지 질의에 대한 문서는 결과를 얻기 위해 데이터베이스 연결을 사용하고 있음을 나타냅니다. – GoingTharn
고마워요. 내가 살펴볼 것입니다. – jcslzr