0

我需要在 php zend 框架中使用 mysql 函数

场景如下:

有一个在 zend 框架中实现的连接查询。我需要从

一个mysql函数。例如,下面是一个mysql函数

CREATE FUNCTION `junk`.`MakeDateList`
    -> (
    ->   BeginDate DATE,
    ->   EndDate DATE,
    ->   InclusionList VARCHAR(20)
    -> )
    -> RETURNS VARCHAR(4096)
    -> DETERMINISTIC
    -> BEGIN
    ->   DECLARE RunningDate DATE;
    ->   DECLARE rv VARCHAR(4096);
    ->   DECLARE comma CHAR(1);
    ->   DECLARE IncList,DOWValue VARCHAR(20);
    ->   DECLARE OK_To_Add INT;
    ->
    ->   SET IncList = CONCAT(',',InclusionList,',');
    ->   SET comma = '';
    ->   SET rv = '';
    ->   SET RunningDate = BeginDate;
    ->   WHILE RunningDate <= EndDate DO
    ->     SET OK_To_Add = 0;
    ->     SET DOWValue = CONCAT(',',DAYOFWEEK(RunningDate),',');
    ->     IF LOCATE(DOWValue,IncList) > 0 THEN
    ->       SET OK_To_Add = 1;
    ->     END IF;
    ->     IF OK_To_Add = 1 THEN
    ->       SET rv = CONCAT(rv,comma,RunningDate);
    ->       SET comma = ',';
    ->     END IF;
    ->     SET RunningDate = RunningDate + INTERVAL 1 DAY;
    ->   END WHILE;
    ->   RETURN rv;
    -> END $$

我需要在我的 zend 框架的 join 函数中使用它,以便所需的输出应该

在新列中可用

有没有什么办法或者方法

提前致谢

4

1 回答 1

3

你试过了吗?

Zend_Db::factory('Pdo_Mysql', array(
    'host'             => '127.0.0.1',
    'username'         => 'webuser',
    'password'         => 'xxxxxxxx',
    'dbname'           => 'test',
    'adapterNamespace' => 'MyProject_Db_Adapter'
))->query('CALL MY_PROCEDURE(?, ?, ?)', array($beginDate, $endDate, $inclusionList))
->fetchAll();
于 2013-02-11T14:19:41.383 回答