2010-07-10 3 views
-1

나는 config contian라는 테이블을 가지고 config_name | config_value 내가 그것을 지금 내가 나에게 같은 배열을 제공 PHP 코드를 원하는PHP 배열 어떤 MySQL의 문제

`config_name` | `config_value` 
`articles_limit` | `10` 

같은 의 압축을 알고 articles_limit => 10

당신은 ADODb 같은 데이터베이스 래퍼를 사용하려고하는 것 같아서

답변

1

, 그런 일이 단순히 일반 PHP로

$config=$db->GetAssoc('select config_name, config_value from config'); 

을 것 곳은 것이

같은
$config=array(); 
$result = mysql_query('select config_name, config_value from config'); 
if (!$result) 
{ 
    //handle error 
    die(mysql_error()); 
} 
else 
{ 
    while ($row = mysql_fetch_assoc($result)) 
    { 
     $config[$row['config_name']] = $row['config_value']; 
    } 
    mysql_free_result($result); 
} 
+0

아니요 사용법을 잘 모르겠다. –

+1

일반적인 방법은 모든 것을 작성하는 대신 래퍼를 사용하는 것입니다. –

+0

새 프로그램은 mysqli 확장자를 사용해야합니다. – Artefacto