As per the discussion, i hv created the Table Class and saved the table class under library->Tables(new folder)->user.php.
class User extends Zend_Db_Table_Abstract
{
protected $_schema = 'zfwork';// DB name
protected $_name = 'user';// Table name
protected $_primary = 'ID';// primary key setting.
}
Here do i need to give the other fields(email,phone) also? or not required?
-----------------------
And added the below code to do autoloading of required class.
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload(); IN the bootstrap file(index.php).
Then the below statment is required for table operation?
"require_once 'Zend/Db/Table/Abstract.php';"
-----------------------
While using the below code in the controller page (UserController.php) in the listAction() function, i am not getting the output. Can you plz tell me where is the error and whats the problem? Because its confusing.
$table = new Tables_User();
$users = $table->find(2);
print_r($users);
-----------------------
One more thing is, for DB connection i am using the following code and connected successfully. My question is, if i hv the DB connection then why should i use a separate "Table Classes" like above. And plz tell me the importance of this also.
$options = array('host'=> 'localhost',
'username'=> 'developer',
'password'=> 'success',
'dbname'=> 'test'
);
$db = Zend_Db::factory('Pdo_Mysql', $options);
-----------------------
Please explain the above DB & Table functionality questions with some example.
Last edited by murugesanme : 02-23-2008 at 06:34 AM.
|