命令行经常会执行一些一次性任务,或者cron任务。
//只能在public下执行
// 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';
$application = new Zend_Application(
APPLICATION_ENV,
APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap();
$type='goods';
$config = Zend_Registry::get('upload');
$upload_config = $config[$type];
$productClass = new Application_Model_Goods();
$galleryClass = new Application_Model_Gallery();
$ids = array(18,19,23,24,25);
$goodslist = $galleryClass->getImageByWhere(18);
;;;;
本文介绍了一个PHP命令行脚本示例,该脚本用于执行特定的应用程序任务,并展示了如何设置应用环境、加载配置文件及使用模型进行数据操作。
256

被折叠的 条评论
为什么被折叠?



