2009-07-03 98 views
0

现状:PEAR数据源驱动程序错误

我创建一个客户的网站数据库中的用户界面。我知道我可以简单地使用phpMyAdmin,但对我的客户来说太复杂了。相反,我尽管可以尝试一些PEAR软件包。在做了一些研究和下面的教程后,我决定使用Structures_DataGrid包。我目前正在关注sitepoint.com的书“The PHP Anthology”。它包含一些很棒的教程。

错误:

首先,我遇到了一些困难,安装包,这样我结束了从PEAR网站下载它们,将它们插入诠释通过FTP服务器他。在完成所有设置之后,我按照本书的说明去了最后一个分号。但我得到这个错误:未知的DataSource驱动程序。请指定现有的驱动程序。我不知道这个错误来自哪里或为什么。

代码:

<?php 

    // Include PEAR::Structures_DataGrid 
    include('Structures/DataGrid.php'); 

    $datagrid = new Structures_DataGrid(2); 
    $options = array('dsn' => 'mysql://$user:[email protected]$db_host/$db_name'); 
    $sql = "SELECT * FROM Users"; 
    $bind = $datagrid->bind($sql, $options); 
    if (PEAR::isError($bind)) { 
     print('DataGrid Error: '. $bind->getMessage()); 
     $gridsource = ''; 
    } else { 

     // Define our Column labels, using a 'column' => 'Label' format 
     $columns = array(
      'id' => 'Id', 
      'status' => 'Status', 
      'last_login' => 'Last Login', 
      'startDate' => 'Start Date', 
      'fname' => 'First Name', 
      'lname' => 'Last Name', 
      'email' => 'Email', 
      'cName' => 'Company', 
      'cEmail' => 'Company Email', 
      'cCity' => 'City', 
      'cProvince' => 'Province', 
      'ctr' => 'Country', 
      'cSite' => 'Website'    
     ); 
     $datagrid->generateColumns($columns); 

     // Some more options, for our renderer 
     $renderer_options = array(
      'sortIconASC' => '&uArr;', 
      'sortIconDESC' => '&dArr;', 
      'headerAttributes' => array('bgcolor' => '#E3E3E3'), 
      'evenRowAttributes' => array('bgcolor' => '#A6A6A6'), 
     ); 
     $datagrid->setRendererOptions($renderer_options); 

     // Add some final attributes to our table 
     $renderer = $datagrid->getRenderer(); 
     $renderer->setTableAttribute('cellspacing', 0); 
     $renderer->setTableAttribute('cellpadding', 5); 
     $renderer->setTableAttribute('border', 1); 

     // Render the table, be sure to check for errors 
     $gridbody = $datagrid->getOutput(); 
     if (PEAR::isError($gridbody)) { 
      print('DataGrid render error: ' . $gridbody->getMessage()); 
      $gridbody = ''; 
     } 

     // Finally, render the pager, again checking for errors 
     $gridpager = $datagrid->getOutput(DATAGRID_RENDER_PAGER); 
     if (PEAR::isError($gridpager)) { 
      print('DataGrid render error: ' . $gridpager->getMessage()); 
      $gridpager = ''; 
     } 
     $gridsource = $gridbody . $gridpager; 
    } 

?> 

评论:

我所有的数据库凭据是正确的。我正尝试连接到Unix服务器上的MySQL数据库。我相信我有所有必需的软件包。我不认为这个错误在代码中。相反,这是驱动程序未启用或类似的问题。

问:

好了,我不知道我的问题是什么,因为我不知道我的问题是什么。我可以问'我如何指定驱动程序?','如何启用/激活/包含驱动程序?'等。或者“以前有没有人处理过这些问题,你做了什么?”

任何帮助将不胜感激,在此先感谢。

回答

1

我真的不知道答案,只是一个更新。

我卸载了一切,并清除了我的服务器上的PHP目录。然后我下载了go-pear.php脚本并重新安装了所有东西。

现在一切正常!好极了!