 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Mon Mar 10, 2008 7:51 pm Post subject: |
|
|
| perpetuallyconfused wrote: | | Oh, I already extracted everything to the PEAR directory (or the Pear/Driver directory). What could be causing this issue otherwise? |
It is pear/MDB2/Driver where the files need to be located. |
|
| Back to top |
|
 |
perpetuallyconfused
Joined: 10 Mar 2008 Posts: 16
|
Posted: Mon Mar 10, 2008 7:58 pm Post subject: |
|
|
| mark wrote: | | perpetuallyconfused wrote: | | Oh, I already extracted everything to the PEAR directory (or the Pear/Driver directory). What could be causing this issue otherwise? |
It is pear/MDB2/Driver where the files need to be located. |
Sorry, yeah, that's where I extracted it. Where ever the documentation said to extract it, is where I extracted it. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Mon Mar 10, 2008 8:06 pm Post subject: |
|
|
| It's hard to debug then without having access to your system. Last idea: Check whether the missing method is defined in one of the files in your PEAR folder. If it isn't, you still have old files there. |
|
| Back to top |
|
 |
perpetuallyconfused
Joined: 10 Mar 2008 Posts: 16
|
Posted: Mon Mar 10, 2008 8:39 pm Post subject: |
|
|
| I think I have old files, but when I try to extract the .tar file for the updated MDB2 drivers, nothing happens (using WinRAR). Is there a .zip file of that upgrade anywhere? |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Mon Mar 10, 2008 11:04 pm Post subject: |
|
|
| perpetuallyconfused wrote: | | I think I have old files, but when I try to extract the .tar file for the updated MDB2 drivers, nothing happens (using WinRAR). Is there a .zip file of that upgrade anywhere? |
No, there is no official .zip file. .tgz is an abbreviation for .tar.gz, maybe renaming makes it easier to open it for you? If not, try "Total Commander", it can handle these files very well. |
|
| Back to top |
|
 |
perpetuallyconfused
Joined: 10 Mar 2008 Posts: 16
|
Posted: Wed Mar 19, 2008 5:39 pm Post subject: |
|
|
I'm now getting the following error:
| Quote: | | Fatal error: Class 'DB' not found in C:\onestopfs\include\database.php on line 12 |
For this line of code:
| Code: | | $this->db = DB::connect($connectionString, USE_PERSISTENT_CONNECTIONS); |
I'm guessing I'm just using an old extension. I'm doing this out of a book, so I guess the book is no good? Or can I just update the class I'm using? |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Wed Mar 19, 2008 5:51 pm Post subject: |
|
|
| DB != MDB2, you're mixing the packages. Which one do you want to use? In your require_once call, you have to include the right file, either DB.php or MDB2.php. |
|
| Back to top |
|
 |
perpetuallyconfused
Joined: 10 Mar 2008 Posts: 16
|
Posted: Thu Mar 20, 2008 8:29 pm Post subject: |
|
|
When I installed the MySQL.php drivers, was I supposed to delete the common.php files that were already there?
I'm now getting this error when trying to define the following function:
| Code: | // wrapper class for PEAR DB's getAll() method
public function DbGetAll($queryString)
{
$result = $this->db->getAll($queryString);
if (MDB2::isError($result))
trigger_error($result->getMessage(), E_USER_ERROR);
return $result;
} |
Error:
| Quote: | ERRNO: 256
Text: Call to undefined function: MDB2_Driver_mysql::getAll().
LOCATION: C:\web\libs\PEAR\MDB2.php, line 1972, at March 20, 2008, 3:10 pm
Showing backtrace:
trigger_error("Call to undefined function: MDB2_Driver_mysql::getAll().", "256") # line 1972, file: C:\web\libs\PEAR\MDB2.php
MDB2_Driver_Common . __call("getAll", Array[1]) # line 0, file: unknown
MDB2_Driver_mysql . getAll("SELECT department_id, name FROM department") # line 36, file: C:\web\include\database.php
DbManager . DbGetAll("SELECT department_id, name FROM department") # line 16, file: C:\web\data_objects\do_catalog.php
DoCatalog . GetDepartments() # line 19, file: C:\web\business_objects\bo_catalog.php
BoCatalog . GetDepartments() # line 38, file: C:\web\smarty_plugins\function.load_departments_list.php
DepartmentsList . init() # line 6, file: C:\web\smarty_plugins\function.load_departments_list.php
smarty_function_load_departments_list(Array[1], Object:Page) # line 5, file: C:\web\templates_c\%%A5^A5A^A5A1C73D%%departments_list.tpl.php
include("C:\web\templates_c\%%A5^A5A^A5A1C73D%%departments_list.tpl...") # line 1868, file: C:\web\libs\smarty\Smarty.class.php
Smarty . _smarty_include(Array[2]) # line 25, file: C:\web\templates_c\%%45^45E^45E480CD%%index.tpl.php
include("C:\web\templates_c\%%45^45E^45E480CD%%index.tpl.php") # line 1255, file: C:\web\libs\smarty\Smarty.class.php
Smarty . fetch("index.tpl", null, null, true) # line 1105, file: C:\web\libs\smarty\Smarty.class.php
Smarty . display("index.tpl") # line 8, file: C:\web\index.php
|
|
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Fri Mar 21, 2008 12:07 am Post subject: |
|
|
| perpetuallyconfused wrote: | | When I installed the MySQL.php drivers, was I supposed to delete the common.php files that were already there? |
No, why do you think you should do that? (What you should, though, is to use the PEAR installer in favor of playing yourself with PEAR files.)
| perpetuallyconfused wrote: | | I'm now getting this error when trying to define the following function: |
RTFM, getAll() is part of the Extended module:
http://pear.php.net/manual/en/package.database.mdb2.intro-module.php |
|
| Back to top |
|
 |
perpetuallyconfused
Joined: 10 Mar 2008 Posts: 16
|
Posted: Fri Mar 21, 2008 4:41 pm Post subject: |
|
|
| mark wrote: | | perpetuallyconfused wrote: | | When I installed the MySQL.php drivers, was I supposed to delete the common.php files that were already there? |
No, why do you think you should do that? (What you should, though, is to use the PEAR installer in favor of playing yourself with PEAR files.) |
I did use the PEAR installer, but apparently, some things either don't get installed automatically, or it didn't install correctly.
From that link, it looks like the extended class is part of MDB2. I can't seem to find an additional file to download from it, so I'm at loss for what you're meaning me to do. |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Fri Mar 21, 2008 4:44 pm Post subject: |
|
|
| You have to load the module, otherwise you can't access its methods. How the module is loaded, is explained on that page. |
|
| Back to top |
|
 |
perpetuallyconfused
Joined: 10 Mar 2008 Posts: 16
|
Posted: Fri Mar 21, 2008 5:42 pm Post subject: |
|
|
| mark wrote: | | You have to load the module, otherwise you can't access its methods. How the module is loaded, is explained on that page. |
So if the code for the page I use that module on is:
| Code: | <?php
// reference the PEAR DB library
require_once 'MDB2.php';
// class providing generic data access functionality
class DbManager
{
public $db;
// open database connection in the constructor
function __construct($connectionString)
{
$this->db = MDB2::connect($connectionString, USE_PERSISTENT_CONNECTIONS);
if (MDB2::isError($this->db))
trigger_error($this->db->getMessage(), E_USER_ERROR);
$this->db->setFetchMode(MDB2_FETCHMODE_ASSOC);
}
// close the connection
public function DbDisconnect()
{
$this->db->disconnect();
}
// wrapper class for PEAR DB's query() method
public function DbQuery($queryString)
{
$result = $this->db->query($queryString);
if (MDB2::isError($result))
trigger_error($result->getMessage(), E_USER_ERROR);
return $result;
}
// wrapper class for PEAR DB's getAll() method
public function DbGetAll($queryString)
{
$result = $this->db->getAll($queryString);
if (MDB2::isError($result))
trigger_error($result->getMessage(), E_USER_ERROR);
return $result;
}
// wrapper class for PEAR DB's getRow() method
public function DbGetRow($queryString)
{
$result = $this->db->getRow($queryString);
if (MDB2::isError($result))
trigger_error($result->getMessage(), E_USER_ERROR);
return $result;
}
// wrapper class for PEAR DB's getOne() method
public function DbGetOne($queryString)
{
$result = $this->db->getOne($queryString);
if (MDB2::isError($result))
trigger_error($result->getMessage(), E_USER_ERROR);
return $result;
}
}
?> |
Is this the page I load the module on? If so, where do I put this code:
| Code: |
$mdb2->loadModule('Manager');
// specifically stating that the module that is being loaded is RDBMS independent
// this works around some needless internal calls
$mdb2->loadModule('Extended', null, false);
|
Or is the loading code on the link you gave me something I have to put as another file and load it using a require_once? |
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Fri Mar 21, 2008 6:34 pm Post subject: |
|
|
You only need this line:
| Code: |
$mdb2->loadModule('Extended', null, false);
|
The Manager module is a different module that you activate if you really need it.
You can put this call either directly after your connect() (or setFetchMode()) call, or you put it before your getAll() call (because only there it is needed). If you want to use multiple methods from this module, it makes more sense to use the first place. |
|
| Back to top |
|
 |
perpetuallyconfused
Joined: 10 Mar 2008 Posts: 16
|
Posted: Fri Mar 21, 2008 7:01 pm Post subject: |
|
|
It doesn't seem to want to let me load this module. Either I get an undefined tag: "mdb2", or I get this error:
| Quote: | | Fatal error: Call to a member function loadModule() on a non-object in C:\onestopfs\include\app_top.php on line 10 |
Depending on where I place it.
Using this code:
| Code: | | $mdb2->loadModule('Extended', null, false); |
|
|
| Back to top |
|
 |
mark

Joined: 07 Jan 2007 Posts: 1053
|
Posted: Fri Mar 21, 2008 7:22 pm Post subject: |
|
|
| Well, you have to replace $mdb2 by $this->db, of course. PHP can't guess what you mean by $mdb2, and the manual can't guess how you name your variables or objects. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|