是否可以在zend框架中使用mysql函数(不是在内置)?

时间:2013-02-11 14:12:20

标签: php mysql zend-framework

我需要在php zend framework中使用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函数中使用它,以便所需的输出

可在新专栏中找到

有没有办法或方法

提前致谢

1 个答案:

答案 0 :(得分: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();