Reputation: 13
I need to use a mysql function in php zend framework
The scenario is as follows:
There is a join query which is implemented in zend framework.I need to get an output from
a mysql function.for example, following is a mysql function
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 $$
I need to use this in my join function of zend framework,so that a desired output should
be available in a new column
Is there any way or method
Thanks in advance
Upvotes: 0
Views: 129
Reputation: 754
Do you tried it?
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();
Upvotes: 3