First thing to check, ensure your PHP executable (php cli) is both using the
same ini values as well as the same extensions as the php apache sapi.  That
might be the reason why you have a mysql driver available in php for apache
but not in the php for cli.

The other issues you are describing are use cases is one that is currently
being discussed in the Zend_Application proposal.

The idea in Zend_Application is that the bootstrap available to the web
application is the same bootstrap available to your projects cli scripts.
This means that you'll have access to your models, database connections,
cache objects, so on and so forth.  Also, you wont be using the Front
Controller, which is unneeded in your cli scripts.

http://framework.zend.com/wiki/display/ZFPROP/Zend_Application+-+Ben+Scholze
n

-ralph


On 2/25/09 1:41 PM, "max_ent" <max_...@hotmail.com> wrote:

> 
> Hi everyone
> 
> I am trying to write command-line accessible scripts that have access to my
> Zend Framework model classes.
> Some of these model classes make database calls. The end goal is to invoke a
> CRON job, which will record user data at regular intervals
> 
> I have followed the advice present in many other posts:
> 
> 1. Created a minimal bootstrap (cli2.php)
> 2. Got the include path correct
> 3. Call the model class after the bootstrap code, in the same file
> 4. Invoke, at the command line, php cli2.php
> 
> I have been stuck at the stage where the model class needs to fetch rows
> from the database, and I get the following error message:
> Fatal error: Uncaught exception 'Zend_Db_Adapter_Exception' with message
> 'The mysql driver is not currently installed' in
> /Users/ak/Zend/workspaces/DefaultWorkspace/testingProject/library/Zend/Db/Adap
> te
> r/Pdo/Abstract.php:116
> Stack trace:
> #0
> /Users/ak/Zend/workspaces/DefaultWorkspace/testingProject/library/Zend/Db/Adap
> ter/Abstract.php(417):
> Zend_Db_Adapter_Pdo_Abstract->_connect()
> #1
> /Users/ak/Zend/workspaces/DefaultWorkspace/testingProject/library/Zend/Db/Adap
> ter/Pdo/Abstract.php(230):
> Zend_Db_Adapter_Abstract->query('SELECT * ?     ...', Array)
> #2
> /Users/ak/Zend/workspaces/DefaultWorkspace/testingProject/library/Zend/Db/Adap
> ter/Abstract.php(663):
> Zend_Db_Adapter_Pdo_Abstract->query('SELECT * ?     ...', Array)
> #3
> /Users/ak/Zend/workspaces/DefaultWorkspace/testingProject/application/default/
> models/User.php(57):
> Zend_Db_Adapter_Abstract->fetchRow('SELECT * ?     ...', Array)
> #4
> /Users/ak/Zend/workspaces/DefaultWorkspace/testingProject/application/cli2.php
> (64):
> User->load()
> #5 {main}
>   thrown in
> /Users/ak/Zend/workspaces/DefaultWorkspace/testingProject/library/Zend/Db/Adap
> ter/Pdo/Abstract.php
> on line 116
> 
> Now, instantiating the User object and calling its load method work from the
> Framework web front end. Can anybody please tell me what I'm doing wrong, in
> that it believes the PDO_MySql driver isn't load
> ed?
>   
> I have also considered using wget against an obscure controller/action path,
> but I feel that this isn't acceptable for security reasons (as the
> originating address can be spoofed). I would like a simple script that can
> be invoked directly from php.
> 
> Any help would be highly appreciated
> 
> Thanks!

-- 
Ralph Schindler
Software Engineer     | ralph.schind...@zend.com
Zend Framework        | http://framework.zend.com/


Reply via email to