命令行运行zend framwork脚本

来源:互联网 发布:迅雷知乎 编辑:程序博客网 时间:2024/05/21 10:58

命令行经常会执行一些一次性任务,或者cron任务。


<?php
//只能在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);
;;;;