Consultez la FAQ sur le ZF avant de poster une question
Vous n'êtes pas identifié.
Pages: 1
Bonjour,
je débute avec z-f. Je voudrais faire une requête dans une class extends de Zend_Form mais je n'arrive pas à configurer mon $db. J'ai tout dabord suivit ce tutoriel
http://s-jdm.developpez.com/tutoriels/p … work-1-10/
Quand je rajoute dans ma page de formulaire ce code:
$registry = Zend_Registry::getInstance();
$db = Zend_Registry::get($db);
Ca me dit que j'ai une erreur.
Pourtant j'ai configuré dans le fichier index.php ainsi:
<?php
// Define path to application directory
defined('APPLICATION_PATH')
|| define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
// Define application environment
defined('APPLICATION_ENV')
|| define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
)));
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
->run();
/** Zend_Application */
require_once 'Zend/View.php';
$view = new Zend_View();
$view->setHelperPath(realpath(APPLICATION_PATH . '/views/helpers'));
/** Zend_Application */
//require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
// Chargement automatique de Zend_Db_Adapter_Pdo_Mysql, et instanciation.
$config = new Zend_Config_Ini('./application/configs/application.ini','repertoire');
$db = Zend_Db::factory($config->database->mysql->adapter,array(
'host' => $config->database->mysql->params->host,
'username' => $config->database->mysql->params->username,
'password' => $config->database->mysql->params->password,
'dbname' => $config->database->mysql->params->dbname,
)
);
$registry = Zend_Registry::getInstance();
// placons la connexion dans un registre global à l'application
$registry->set('db', $db);
// en faire la connexion par defaut
Zend_Db_Table::setDefaultAdapter($db);
$application->bootstrap();
$application->run();
Pourriez-vous me dire de quoi cela provient?
Merci
Hors ligne
Pages: 1