2009年4月30日星期四

Re: [fw-db] Try to create a "join" query

Ok, I have to correct myself.

Try: $this->getAdapter()->select()->from();

Hope, that's it!

Regards dennis

Am 30.04.2009 um 20:09 schrieb lesquale <cedbourgeon@hotmail.com>:

>
> i tried
> but i get another error message :
>
> Fatal error: Call to undefined method
> Zend_Db_Adapter_Pdo_Mysql::from() in
> C:\Program Files\EasyPHP 3.0\www\si\application\models\classes
> \Ce.php on
> line 174
> --
> View this message in context: http://www.nabble.com/Try-to-create-a-%22join%22-query-tp23316634p23321557.html
> Sent from the Zend DB mailing list archive at Nabble.com.
>

Re: [fw-db] Try to create a "join" query

i tried
but i get another error message :

Fatal error: Call to undefined method Zend_Db_Adapter_Pdo_Mysql::from() in
C:\Program Files\EasyPHP 3.0\www\si\application\models\classes\Ce.php on
line 174
--
View this message in context: http://www.nabble.com/Try-to-create-a-%22join%22-query-tp23316634p23321557.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-mvc] Zend_Session with Sqlite DbTable not working

Thanks a lot. This was the solution.


Marcel

Am 30.04.2009 um 12:10 schrieb Viktor Grandgeorg:

> your $config array is missing the primaryAssignment option. You must
> specify this as the default value is 'sessionId' for the
> primary key value and not 'session_id' as in your case. - Have a
> look at the constructor's API documentation in
> Zend/Session/SaveHandler/DbTable.php
>
> Or you modify your dbtable. For me the following works fine:
>
> BEGIN TRANSACTION;
> CREATE TABLE session (sessionId TEXT, sessionName TEXT,
> sessionSavePath TEXT, modified TEXT, data TEXT, lifetime TEXT);
> COMMIT;
>
> Then you can have the $config as follows:
>
> $config = array(
> 'name' => 'session',
> 'primary' => 'sessionId',
> 'modifiedColumn' => 'modified',
> 'dataColumn' => 'data',
> 'lifetimeColumn' => 'lifetime'
> );
>
>
> Have fun
> Viktor
>
>
>> -----Original Message-----
>> From: Marcel Alburg [mailto:m.alburg@weeaar.com]
>> Sent: Tuesday, April 28, 2009 11:37 PM
>> To: fw-mvc@lists.zend.com
>> Subject: [fw-mvc] Zend_Session with Sqlite DbTable not working
>>
>> Hello List,
>>
>> i've a problem if i use Zend_Session with
>> Zend_Session_SaveHandler_DbTable.
>>
>> I've i use the Zend_DB functions, it's not possible to store the
>> sessiondata into the Sqllite DB.
>>
>> I use a normal script without Zend
>>
>> ----
>> $dbh = new PDO('sqlite2:foo.sqlite3');
>>
>> $stmt = $dbh->prepare('INSERT INTO "session" ("session_id",
>> "modified", "session_data", "lifetime") VALUES (?, ?, ?, ?)');
>>
>> if (!$stmt) {
>> echo "\nPDO::errorInfo():\n";
>> print_r($dbh->errorInfo());
>> exit;
>> }
>>
>>
>> $aData = array(
>> '893ac6d16bdfce75018cd7f4bd8cc165',
>> 1240951239,
>> '',
>> 1440
>> );
>>
>> $stmt->execute($aData);
>> ---
>>
>> Works fine.
>>
>> But if i use Zend i get an exception.
>>
>>
>>
>> My Script:
>>
>> -----
>>
>> function exception_handler($e)
>> {
>> print $e->getMessage();
>> exit;
>> }
>>
>> require_once 'Zend/Loader.php';
>>
>> Zend_Loader::registerAutoload('Zend_Loader_Autoloader');
>>
>>
>> $db = Zend_Db::factory('Pdo_Sqlite', array(
>> 'username' => '',
>> 'password' => '',
>> 'dbname' => 'session.sqlite3',
>> 'sqlite2' => '1'
>> ));
>>
>> Zend_Db_Table_Abstract::setDefaultAdapter($db);
>>
>> $config = array(
>> 'name' => 'session',
>> 'primary' => 'session_id',
>> 'modifiedColumn' => 'modified',
>> 'dataColumn' => 'session_data',
>> 'lifetimeColumn' => 'lifetime'
>> );
>>
>>
>> Zend_Session::setSaveHandler(new
>> Zend_Session_SaveHandler_DbTable($config));
>>
>> // Session starten
>> Zend_Session::start();
>> ---
>>
>> gets the Exception:
>>
>> ---
>> SQLSTATE[HY000]: General error: 1 SQL logic error or missing
>> database<hr>EXCEPTION:<br><hr>[Message] => SQLSTATE[HY000]: General
>> error: 1 SQL logic error or missing database<br>[File] => /var/www/
>> tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/Db/S
>> tatement/
>> Pdo.php<br>[Line] => 238<br>[Trace] => <br>#0
>> /var/www/tracking/trunk/
>> library/ZendFramework-1.8.0b1/library/Zend/Db/Statement.php(283):
>> Zend_Db_Statement_Pdo->_execute(Array)
>> #1
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Db/Adapter/Abstract.php(467): Zend_Db_Statement->execute(Array)
>> #2
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Db/Adapter/Pdo/Abstract.php(235): Zend_Db_Adapter_Abstract-
>>> query('DELETE FROM "se...', Array)
>> #3
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Db/Adapter/Abstract.php(632): Zend_Db_Adapter_Pdo_Abstract-
>>> query('DELETE FROM "se...')
>> #4
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Db/Table/Abstract.php(1064): Zend_Db_Adapter_Abstract-
>>> delete('session', Array)
>> #5
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Session/SaveHandler/DbTable.php(380): Zend_Db_Table_Abstract-
>>> delete(Array)
>> #6
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Session/SaveHandler/DbTable.php(322):
>> Zend_Session_SaveHandler_DbTable-
>>> destroy('893ac6d16bdfce7...')
>> #7 [internal function]: Zend_Session_SaveHandler_DbTable-
>>> read('893ac6d16bdfce7...')
>> #8
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Session.php(438): session_start()
>> #9 /var/www/tracking/trunk/framwork/_projects_/Kunba/classes/
>> Controller/Abstract.php(14): Zend_Session::start()
>> #10
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Controller/Action.php(132): Kunba_Controller_Abstract->init()
>> #11
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Controller/Dispatcher/Standard.php(261): Zend_Controller_Action-
>>> __construct(Object(Zend_Controller_Request_Http),
>> Object(Zend_Controller_Response_Http), Array)
>> #12
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Controller/Front.php(936): Zend_Controller_Dispatcher_Standard-
>>> dispatch(Object(Zend_Controller_Request_Http),
>> Object(Zend_Controller_Response_Http))
>> #13 /var/www/tracking/trunk/framwork/_projects_/Kunba/
>> Bootstrap.php(436): Zend_Controller_Front->dispatch()
>> #14
>> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
>> Application.php(302): Kunba_Bootstrap->run()
>> #15 /var/www/tracking/trunk/framwork/index.php(149):
>> Zend_Application-
>>> run()
>> #16 {main}<br>[GET] => Array
>> (
>> )
>> <br>[POST] => Array
>> (
>> )
>> <br>Zend_Db_Statement_Exception Object
>> (
>> [message:protected] => SQLSTATE[HY000]: General error: 1 SQL
>> logic error or missing database
>> [string:private] =>
>> [code:protected] => 0
>> [file:protected] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Db/Statement/Pdo.php
>> [line:protected] => 238
>> [trace:private] => Array
>> (
>> [0] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Db/Statement.php
>> [line] => 283
>> [function] => _execute
>> [class] => Zend_Db_Statement_Pdo
>> [type] => ->
>> [args] => Array
>> (
>> [0] => Array
>> (
>> )
>>
>> )
>>
>> )
>>
>> [1] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Db/Adapter/Abstract.php
>> [line] => 467
>> [function] => execute
>> [class] => Zend_Db_Statement
>> [type] => ->
>> [args] => Array
>> (
>> [0] => Array
>> (
>> )
>>
>> )
>>
>> )
>>
>> [2] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Db/Adapter/Pdo/Abstract.php
>> [line] => 235
>> [function] => query
>> [class] => Zend_Db_Adapter_Abstract
>> [type] => ->
>> [args] => Array
>> (
>> [0] => DELETE FROM "session" WHERE
>> ("session_id" = '893ac6d16bdfce75018cd7f4bd8cc165')
>> [1] => Array
>> (
>> )
>>
>> )
>>
>> )
>>
>> [3] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Db/Adapter/Abstract.php
>> [line] => 632
>> [function] => query
>> [class] => Zend_Db_Adapter_Pdo_Abstract
>> [type] => ->
>> [args] => Array
>> (
>> [0] => DELETE FROM "session" WHERE
>> ("session_id" = '893ac6d16bdfce75018cd7f4bd8cc165')
>> )
>>
>> )
>>
>> [4] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Db/Table/Abstract.php
>> [line] => 1064
>> [function] => delete
>> [class] => Zend_Db_Adapter_Abstract
>> [type] => ->
>> [args] => Array
>> (
>> [0] => session
>> [1] => Array
>> (
>> [0] => "session_id" =
>> '893ac6d16bdfce75018cd7f4bd8cc165'
>> )
>>
>> )
>>
>> )
>>
>> [5] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Session/SaveHandler/DbTable.php
>> [line] => 380
>> [function] => delete
>> [class] => Zend_Db_Table_Abstract
>> [type] => ->
>> [args] => Array
>> (
>> [0] => Array
>> (
>> [0] => "session_id" =
>> '893ac6d16bdfce75018cd7f4bd8cc165'
>> )
>>
>> )
>>
>> )
>>
>> [6] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Session/SaveHandler/DbTable.php
>> [line] => 322
>> [function] => destroy
>> [class] => Zend_Session_SaveHandler_DbTable
>> [type] => ->
>> [args] => Array
>> (
>> [0] => 893ac6d16bdfce75018cd7f4bd8cc165
>> )
>>
>> )
>>
>> [7] => Array
>> (
>> [function] => read
>> [class] => Zend_Session_SaveHandler_DbTable
>> [type] => ->
>> [args] => Array
>> (
>> [0] => 893ac6d16bdfce75018cd7f4bd8cc165
>> )
>>
>> )
>>
>> [8] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Session.php
>> [line] => 438
>> [function] => session_start
>> [args] => Array
>> (
>> )
>>
>> )
>>
>> [9] => Array
>> (
>> [file] => /var/www/tracking/trunk/framwork/
>> _projects_/Kunba/classes/Controller/Abstract.php
>> [line] => 14
>> [function] => start
>> [class] => Zend_Session
>> [type] => ::
>> [args] => Array
>> (
>> )
>>
>> )
>>
>> [10] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Controller/Action.php
>> [line] => 132
>> [function] => init
>> [class] => Kunba_Controller_Abstract
>> [type] => ->
>> [args] => Array
>> (
>> )
>>
>> )
>>
>> [11] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Controller/Dispatcher/Standard.php
>> [line] => 261
>> [function] => __construct
>> [class] => Zend_Controller_Action
>> [type] => ->
>> [args] => Array
>> (
>> [0] =>
>> Zend_Controller_Request_Http Object
>> (
>>
>> [_paramSources:protected] => Array
>> (
>> [0] => _GET
>> [1] => _POST
>> )
>>
>> [_requestUri:protected] => /
>> [_baseUrl:protected] =>
>> [_basePath:protected] =>
>> [_pathInfo:protected] => /
>> [_params:protected] => Array
>> (
>> [controller] => index
>> [action] => index
>> [module] => Kunba
>> )
>>
>> [_aliases:protected] => Array
>> (
>> )
>>
>> [_dispatched:protected] => 1
>> [_module:protected] => Kunba
>> [_moduleKey:protected] => module
>> [_controller:protected] => index
>> [_controllerKey:protected] =>
>> controller
>> [_action:protected] => index
>> [_actionKey:protected] => action
>> )
>>
>> [1] =>
>> Zend_Controller_Response_Http Object
>> (
>> [_body:protected] => Array
>> (
>> )
>>
>> [_exceptions:protected] => Array
>> (
>> )
>>
>> [_headers:protected] => Array
>> (
>> )
>>
>> [_headersRaw:protected] => Array
>> (
>> )
>>
>>
>> [_httpResponseCode:protected] =>
>> 200
>> [_isRedirect:protected] =>
>> [_renderExceptions:protected] =>
>> [headersSentThrowsException] => 1
>> )
>>
>> [2] => Array
>> (
>> [prefixDefaultModule] => 1
>> )
>>
>> )
>>
>> )
>>
>> [12] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Controller/Front.php
>> [line] => 936
>> [function] => dispatch
>> [class] => Zend_Controller_Dispatcher_Standard
>> [type] => ->
>> [args] => Array
>> (
>> [0] =>
>> Zend_Controller_Request_Http Object
>> (
>>
>> [_paramSources:protected] => Array
>> (
>> [0] => _GET
>> [1] => _POST
>> )
>>
>> [_requestUri:protected] => /
>> [_baseUrl:protected] =>
>> [_basePath:protected] =>
>> [_pathInfo:protected] => /
>> [_params:protected] => Array
>> (
>> [controller] => index
>> [action] => index
>> [module] => Kunba
>> )
>>
>> [_aliases:protected] => Array
>> (
>> )
>>
>> [_dispatched:protected] => 1
>> [_module:protected] => Kunba
>> [_moduleKey:protected] => module
>> [_controller:protected] => index
>> [_controllerKey:protected] =>
>> controller
>> [_action:protected] => index
>> [_actionKey:protected] => action
>> )
>>
>> [1] =>
>> Zend_Controller_Response_Http Object
>> (
>> [_body:protected] => Array
>> (
>> )
>>
>> [_exceptions:protected] => Array
>> (
>> )
>>
>> [_headers:protected] => Array
>> (
>> )
>>
>> [_headersRaw:protected] => Array
>> (
>> )
>>
>>
>> [_httpResponseCode:protected] =>
>> 200
>> [_isRedirect:protected] =>
>> [_renderExceptions:protected] =>
>> [headersSentThrowsException] => 1
>> )
>>
>> )
>>
>> )
>>
>> [13] => Array
>> (
>> [file] => /var/www/tracking/trunk/framwork/
>> _projects_/Kunba/Bootstrap.php
>> [line] => 436
>> [function] => dispatch
>> [class] => Zend_Controller_Front
>> [type] => ->
>> [args] => Array
>> (
>> )
>>
>> )
>>
>> [14] => Array
>> (
>> [file] => /var/www/tracking/trunk/library/
>> ZendFramework-1.8.0b1/library/Zend/Application.php
>> [line] => 302
>> [function] => run
>> [class] => Kunba_Bootstrap
>> [type] => ->
>> [args] => Array
>> (
>> )
>>
>> )
>>
>> [15] => Array
>> (
>> [file] => /var/www/tracking/trunk/framwork/
>> index.php
>> [line] => 149
>> [function] => run
>> [class] => Zend_Application
>> [type] => ->
>> [args] => Array
>> (
>> )
>>
>> )
>>
>> )
>>
>> )
>> --
>>
>>
>> Thanks a lot
>>
>> Marcel Alburg
>>
>
>

Re: [fw-mvc] Action ContextSwitch

But how do I know formats needed in advance? Contexts set in controller::init.

And what about exclusiveness?

> Try setting the request's format parameter in your controller's
> preDispatch() hook:
> $this->_request->setParam('format', 'xml');
>
>>
>> Please, help to get idea of contexts.
>> There are questons I cannot find answers by now.
>> Is there a way to hint context (xml, for example) without explicitly
>> putting format var into request?
>> How to set exclusive context for an action (the way that all requests
>> to that particular action will be processed only in context specified,
>> without any hints)?
>>

Re: [fw-db] Try to create a "join" query

Try to use $this->getAdapter()->from()

Kind regards

Am 30.04.2009 um 17:08 schrieb lesquale <cedbourgeon@hotmail.com>:

>
> Someone helped me on another forum
>
> here is the source code i got for now :
>
> $max = $this->select()
> ->from($this, array(
> 'etudiant_id',
> 'periode_id',
> //'versionmax' => new Zend_Db_Expr('max(ce_version)')))
> 'versionmax' => 'max(ce_version)'))
> ->where('etudiant_id = "'.$etudiant.'"')
> ->group(array('etudiant_id', 'periode_id'));
>
> $select = $this->select()->setIntegrityCheck(false);
> $select->from(array('CE' => $this))
> ->join(
> //array('CEMAX'=> new Zend_Db_Expr($max)),
> array('CEMAX'=> $max),
> 'etudiant_id = CEMAX.etudiant_id',
> array()
> )
> ->where('CE.etudiant_id = 1 and CE.periode_id =
> CEMAX.periode_id AND
> CE.ce_version = CEMAX.versionmax')
> ->order('ce_version', 'DESC');
>
> $result = $this->fetchAll($select)->toArray();
>
>
>
> But now i got a server-side error message :
>
> Fatal error: Uncaught exception 'Zend_Db_Table_Select_Exception' with
> message 'Select query cannot join with another table'
>
> i read "$_dependantTables" and "$_referenceMap" variables have to be
> created
> - i did it
> and also "setIntegrityCheck(false)" method must be used with
> select() - i
> did it too
>
> with those changes, i got the following message :
>
> Catchable fatal error: Object of class Ce could not be converted to
> string
> in C:\www\si\library\Zend\Db\Adapter\Abstract.php on line 958
> --
> View this message in context: http://www.nabble.com/Try-to-create-a-%22join%22-query-tp23316634p23318273.html
> Sent from the Zend DB mailing list archive at Nabble.com.
>

Re: [fw-mvc] Zend_Layout with multiple contentKeys

calling $controller->render(null, 'your-action-content-key'); seems to be for this (or do i miss sthg?).
So far, worked for me quite well.
Remy

On Thu, Apr 30, 2009 at 5:06 PM, Jurian Sluiman <subscribe@juriansluiman.nl> wrote:
Hi all,
I'm quite new to ZF but manage to create some complex systems in a sort time.
One thing I don't get is creating content into more than one content key from
Zend_Layout.

I want to dispatch more things in the dispatch loop. Therefore, I have a
plugin with a postDispatch() hook. It looks if there need to be an iteration
again, it sets the request object with the new data and reset the dispatched
flag.
The content of both (or even more) loops should not always be stored in the
same key (default: content). It is possible to have one action stored in the
key "one" and the second one in "two". To manage it I created a preDispatch()
hook which sets the content key (setContentKey()) before each dispatch (of
course only when it's defined to have a custom content key).

The result is not what I want: all the content is appended into one key, the
last one which is set through setContentKey().

How is it possible to manage the result I'd like? Thanks in advance for any
help!
Best regards,
Jurian Sluiman


Re: [fw-db] Try to create a "join" query

Someone helped me on another forum

here is the source code i got for now :

$max = $this->select()
->from($this, array(
'etudiant_id',
'periode_id',
//'versionmax' => new Zend_Db_Expr('max(ce_version)')))
'versionmax' => 'max(ce_version)'))
->where('etudiant_id = "'.$etudiant.'"')
->group(array('etudiant_id', 'periode_id'));

$select = $this->select()->setIntegrityCheck(false);
$select->from(array('CE' => $this))
->join(
//array('CEMAX'=> new Zend_Db_Expr($max)),
array('CEMAX'=> $max),
'etudiant_id = CEMAX.etudiant_id',
array()
)
->where('CE.etudiant_id = 1 and CE.periode_id = CEMAX.periode_id AND
CE.ce_version = CEMAX.versionmax')
->order('ce_version', 'DESC');

$result = $this->fetchAll($select)->toArray();

But now i got a server-side error message :

Fatal error: Uncaught exception 'Zend_Db_Table_Select_Exception' with
message 'Select query cannot join with another table'

i read "$_dependantTables" and "$_referenceMap" variables have to be created
- i did it
and also "setIntegrityCheck(false)" method must be used with select() - i
did it too

with those changes, i got the following message :

Catchable fatal error: Object of class Ce could not be converted to string
in C:\www\si\library\Zend\Db\Adapter\Abstract.php on line 958
--
View this message in context: http://www.nabble.com/Try-to-create-a-%22join%22-query-tp23316634p23318273.html
Sent from the Zend DB mailing list archive at Nabble.com.

[fw-mvc] Zend_Layout with multiple contentKeys

Hi all,
I'm quite new to ZF but manage to create some complex systems in a sort time.
One thing I don't get is creating content into more than one content key from
Zend_Layout.

I want to dispatch more things in the dispatch loop. Therefore, I have a
plugin with a postDispatch() hook. It looks if there need to be an iteration
again, it sets the request object with the new data and reset the dispatched
flag.
The content of both (or even more) loops should not always be stored in the
same key (default: content). It is possible to have one action stored in the
key "one" and the second one in "two". To manage it I created a preDispatch()
hook which sets the content key (setContentKey()) before each dispatch (of
course only when it's defined to have a custom content key).

The result is not what I want: all the content is appended into one key, the
last one which is set through setContentKey().

How is it possible to manage the result I'd like? Thanks in advance for any
help!
Best regards,
Jurian Sluiman

Re: [fw-mvc] How to fetch the original file name from upload element (BC break?)

If you want to have the filename of the original file you must call
getFileName() BEFORE you receive the file.
Reason is that the filename will be changed by the rename filter when you
receive the file.

So, simply call getFileName before calling getValues() or receive().

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

----- Original Message -----
From: "Емил Иванов / Emil Ivanov" <emil.vladev@gmail.com>
To: <fw-mvc@lists.zend.com>
Sent: Thursday, April 30, 2009 3:07 PM
Subject: [fw-mvc] How to fetch the original file name from upload element
(BC break?)


> In the code I was doing
>
> $originalFileName = $attachment->getFileName(null, false);
>
> to get the name of the file uploaded, but since I use the rename
> filter now I get the name after the renaming.
>
> It used to work?!?
>
> Regards,
> Emil
>
> --
> My place to share my ideas:
> http://bolddream.com (under contruction)

[fw-db] Try to create a "join" query

Hi,

i try to create a query (unsuccessfully for now) based on this SQL query :

SELECT CE . *
FROM CE
JOIN (
SELECT etudiant_id, periode_id, max( ce_version ) AS versionmax
FROM CE
GROUP BY etudiant_id, periode_id
)CEMAX ON CE.etudiant_id = CEMAX.etudiant_id
WHERE CE.periode_id = CEMAX.periode_id
AND CE.ce_version = CEMAX.versionmax
AND CE.etudiant_id = "1"
ORDER BY `CE`.`ce_version` DESC


if someone knows how to do, please tell me.

by advance, thanks

Ced.
--
View this message in context: http://www.nabble.com/Try-to-create-a-%22join%22-query-tp23316634p23316634.html
Sent from the Zend DB mailing list archive at Nabble.com.

[fw-mvc] How to fetch the original file name from upload element (BC break?)

In the code I was doing

$originalFileName = $attachment->getFileName(null, false);

to get the name of the file uploaded, but since I use the rename
filter now I get the name after the renaming.

It used to work?!?

Regards,
Emil

--
My place to share my ideas:
http://bolddream.com (under contruction)

RE: [fw-mvc] Zend_Session with Sqlite DbTable not working

your $config array is missing the primaryAssignment option. You must specify this as the default value is 'sessionId' for the
primary key value and not 'session_id' as in your case. - Have a look at the constructor's API documentation in
Zend/Session/SaveHandler/DbTable.php

Or you modify your dbtable. For me the following works fine:

BEGIN TRANSACTION;
CREATE TABLE session (sessionId TEXT, sessionName TEXT, sessionSavePath TEXT, modified TEXT, data TEXT, lifetime TEXT);
COMMIT;

Then you can have the $config as follows:

$config = array(
'name' => 'session',
'primary' => 'sessionId',
'modifiedColumn' => 'modified',
'dataColumn' => 'data',
'lifetimeColumn' => 'lifetime'
);


Have fun
Viktor


> -----Original Message-----
> From: Marcel Alburg [mailto:m.alburg@weeaar.com]
> Sent: Tuesday, April 28, 2009 11:37 PM
> To: fw-mvc@lists.zend.com
> Subject: [fw-mvc] Zend_Session with Sqlite DbTable not working
>
> Hello List,
>
> i've a problem if i use Zend_Session with
> Zend_Session_SaveHandler_DbTable.
>
> I've i use the Zend_DB functions, it's not possible to store the
> sessiondata into the Sqllite DB.
>
> I use a normal script without Zend
>
> ----
> $dbh = new PDO('sqlite2:foo.sqlite3');
>
> $stmt = $dbh->prepare('INSERT INTO "session" ("session_id",
> "modified", "session_data", "lifetime") VALUES (?, ?, ?, ?)');
>
> if (!$stmt) {
> echo "\nPDO::errorInfo():\n";
> print_r($dbh->errorInfo());
> exit;
> }
>
>
> $aData = array(
> '893ac6d16bdfce75018cd7f4bd8cc165',
> 1240951239,
> '',
> 1440
> );
>
> $stmt->execute($aData);
> ---
>
> Works fine.
>
> But if i use Zend i get an exception.
>
>
>
> My Script:
>
> -----
>
> function exception_handler($e)
> {
> print $e->getMessage();
> exit;
> }
>
> require_once 'Zend/Loader.php';
>
> Zend_Loader::registerAutoload('Zend_Loader_Autoloader');
>
>
> $db = Zend_Db::factory('Pdo_Sqlite', array(
> 'username' => '',
> 'password' => '',
> 'dbname' => 'session.sqlite3',
> 'sqlite2' => '1'
> ));
>
> Zend_Db_Table_Abstract::setDefaultAdapter($db);
>
> $config = array(
> 'name' => 'session',
> 'primary' => 'session_id',
> 'modifiedColumn' => 'modified',
> 'dataColumn' => 'session_data',
> 'lifetimeColumn' => 'lifetime'
> );
>
>
> Zend_Session::setSaveHandler(new
> Zend_Session_SaveHandler_DbTable($config));
>
> // Session starten
> Zend_Session::start();
> ---
>
> gets the Exception:
>
> ---
> SQLSTATE[HY000]: General error: 1 SQL logic error or missing
> database<hr>EXCEPTION:<br><hr>[Message] => SQLSTATE[HY000]: General
> error: 1 SQL logic error or missing database<br>[File] => /var/www/
> tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/Db/S
> tatement/
> Pdo.php<br>[Line] => 238<br>[Trace] => <br>#0
> /var/www/tracking/trunk/
> library/ZendFramework-1.8.0b1/library/Zend/Db/Statement.php(283):
> Zend_Db_Statement_Pdo->_execute(Array)
> #1
> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
> Db/Adapter/Abstract.php(467): Zend_Db_Statement->execute(Array)
> #2
> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
> Db/Adapter/Pdo/Abstract.php(235): Zend_Db_Adapter_Abstract-
> >query('DELETE FROM "se...', Array)
> #3
> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
> Db/Adapter/Abstract.php(632): Zend_Db_Adapter_Pdo_Abstract-
> >query('DELETE FROM "se...')
> #4
> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
> Db/Table/Abstract.php(1064): Zend_Db_Adapter_Abstract-
> >delete('session', Array)
> #5
> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
> Session/SaveHandler/DbTable.php(380): Zend_Db_Table_Abstract-
> >delete(Array)
> #6
> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
> Session/SaveHandler/DbTable.php(322):
> Zend_Session_SaveHandler_DbTable-
> >destroy('893ac6d16bdfce7...')
> #7 [internal function]: Zend_Session_SaveHandler_DbTable-
> >read('893ac6d16bdfce7...')
> #8
> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
> Session.php(438): session_start()
> #9 /var/www/tracking/trunk/framwork/_projects_/Kunba/classes/
> Controller/Abstract.php(14): Zend_Session::start()
> #10
> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
> Controller/Action.php(132): Kunba_Controller_Abstract->init()
> #11
> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
> Controller/Dispatcher/Standard.php(261): Zend_Controller_Action-
> >__construct(Object(Zend_Controller_Request_Http),
> Object(Zend_Controller_Response_Http), Array)
> #12
> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
> Controller/Front.php(936): Zend_Controller_Dispatcher_Standard-
> >dispatch(Object(Zend_Controller_Request_Http),
> Object(Zend_Controller_Response_Http))
> #13 /var/www/tracking/trunk/framwork/_projects_/Kunba/
> Bootstrap.php(436): Zend_Controller_Front->dispatch()
> #14
> /var/www/tracking/trunk/library/ZendFramework-1.8.0b1/library/Zend/
> Application.php(302): Kunba_Bootstrap->run()
> #15 /var/www/tracking/trunk/framwork/index.php(149):
> Zend_Application-
> >run()
> #16 {main}<br>[GET] => Array
> (
> )
> <br>[POST] => Array
> (
> )
> <br>Zend_Db_Statement_Exception Object
> (
> [message:protected] => SQLSTATE[HY000]: General error: 1 SQL
> logic error or missing database
> [string:private] =>
> [code:protected] => 0
> [file:protected] => /var/www/tracking/trunk/library/
> ZendFramework-1.8.0b1/library/Zend/Db/Statement/Pdo.php
> [line:protected] => 238
> [trace:private] => Array
> (
> [0] => Array
> (
> [file] => /var/www/tracking/trunk/library/
> ZendFramework-1.8.0b1/library/Zend/Db/Statement.php
> [line] => 283
> [function] => _execute
> [class] => Zend_Db_Statement_Pdo
> [type] => ->
> [args] => Array
> (
> [0] => Array
> (
> )
>
> )
>
> )
>
> [1] => Array
> (
> [file] => /var/www/tracking/trunk/library/
> ZendFramework-1.8.0b1/library/Zend/Db/Adapter/Abstract.php
> [line] => 467
> [function] => execute
> [class] => Zend_Db_Statement
> [type] => ->
> [args] => Array
> (
> [0] => Array
> (
> )
>
> )
>
> )
>
> [2] => Array
> (
> [file] => /var/www/tracking/trunk/library/
> ZendFramework-1.8.0b1/library/Zend/Db/Adapter/Pdo/Abstract.php
> [line] => 235
> [function] => query
> [class] => Zend_Db_Adapter_Abstract
> [type] => ->
> [args] => Array
> (
> [0] => DELETE FROM "session" WHERE
> ("session_id" = '893ac6d16bdfce75018cd7f4bd8cc165')
> [1] => Array
> (
> )
>
> )
>
> )
>
> [3] => Array
> (
> [file] => /var/www/tracking/trunk/library/
> ZendFramework-1.8.0b1/library/Zend/Db/Adapter/Abstract.php
> [line] => 632
> [function] => query
> [class] => Zend_Db_Adapter_Pdo_Abstract
> [type] => ->
> [args] => Array
> (
> [0] => DELETE FROM "session" WHERE
> ("session_id" = '893ac6d16bdfce75018cd7f4bd8cc165')
> )
>
> )
>
> [4] => Array
> (
> [file] => /var/www/tracking/trunk/library/
> ZendFramework-1.8.0b1/library/Zend/Db/Table/Abstract.php
> [line] => 1064
> [function] => delete
> [class] => Zend_Db_Adapter_Abstract
> [type] => ->
> [args] => Array
> (
> [0] => session
> [1] => Array
> (
> [0] => "session_id" =
> '893ac6d16bdfce75018cd7f4bd8cc165'
> )
>
> )
>
> )
>
> [5] => Array
> (
> [file] => /var/www/tracking/trunk/library/
> ZendFramework-1.8.0b1/library/Zend/Session/SaveHandler/DbTable.php
> [line] => 380
> [function] => delete
> [class] => Zend_Db_Table_Abstract
> [type] => ->
> [args] => Array
> (
> [0] => Array
> (
> [0] => "session_id" =
> '893ac6d16bdfce75018cd7f4bd8cc165'
> )
>
> )
>
> )
>
> [6] => Array
> (
> [file] => /var/www/tracking/trunk/library/
> ZendFramework-1.8.0b1/library/Zend/Session/SaveHandler/DbTable.php
> [line] => 322
> [function] => destroy
> [class] => Zend_Session_SaveHandler_DbTable
> [type] => ->
> [args] => Array
> (
> [0] => 893ac6d16bdfce75018cd7f4bd8cc165
> )
>
> )
>
> [7] => Array
> (
> [function] => read
> [class] => Zend_Session_SaveHandler_DbTable
> [type] => ->
> [args] => Array
> (
> [0] => 893ac6d16bdfce75018cd7f4bd8cc165
> )
>
> )
>
> [8] => Array
> (
> [file] => /var/www/tracking/trunk/library/
> ZendFramework-1.8.0b1/library/Zend/Session.php
> [line] => 438
> [function] => session_start
> [args] => Array
> (
> )
>
> )
>
> [9] => Array
> (
> [file] => /var/www/tracking/trunk/framwork/
> _projects_/Kunba/classes/Controller/Abstract.php
> [line] => 14
> [function] => start
> [class] => Zend_Session
> [type] => ::
> [args] => Array
> (
> )
>
> )
>
> [10] => Array
> (
> [file] => /var/www/tracking/trunk/library/
> ZendFramework-1.8.0b1/library/Zend/Controller/Action.php
> [line] => 132
> [function] => init
> [class] => Kunba_Controller_Abstract
> [type] => ->
> [args] => Array
> (
> )
>
> )
>
> [11] => Array
> (
> [file] => /var/www/tracking/trunk/library/
> ZendFramework-1.8.0b1/library/Zend/Controller/Dispatcher/Standard.php
> [line] => 261
> [function] => __construct
> [class] => Zend_Controller_Action
> [type] => ->
> [args] => Array
> (
> [0] =>
> Zend_Controller_Request_Http Object
> (
>
> [_paramSources:protected] => Array
> (
> [0] => _GET
> [1] => _POST
> )
>
> [_requestUri:protected] => /
> [_baseUrl:protected] =>
> [_basePath:protected] =>
> [_pathInfo:protected] => /
> [_params:protected] => Array
> (
> [controller] => index
> [action] => index
> [module] => Kunba
> )
>
> [_aliases:protected] => Array
> (
> )
>
> [_dispatched:protected] => 1
> [_module:protected] => Kunba
> [_moduleKey:protected] => module
> [_controller:protected] => index
> [_controllerKey:protected] =>
> controller
> [_action:protected] => index
> [_actionKey:protected] => action
> )
>
> [1] =>
> Zend_Controller_Response_Http Object
> (
> [_body:protected] => Array
> (
> )
>
> [_exceptions:protected] => Array
> (
> )
>
> [_headers:protected] => Array
> (
> )
>
> [_headersRaw:protected] => Array
> (
> )
>
>
> [_httpResponseCode:protected] =>
> 200
> [_isRedirect:protected] =>
> [_renderExceptions:protected] =>
> [headersSentThrowsException] => 1
> )
>
> [2] => Array
> (
> [prefixDefaultModule] => 1
> )
>
> )
>
> )
>
> [12] => Array
> (
> [file] => /var/www/tracking/trunk/library/
> ZendFramework-1.8.0b1/library/Zend/Controller/Front.php
> [line] => 936
> [function] => dispatch
> [class] => Zend_Controller_Dispatcher_Standard
> [type] => ->
> [args] => Array
> (
> [0] =>
> Zend_Controller_Request_Http Object
> (
>
> [_paramSources:protected] => Array
> (
> [0] => _GET
> [1] => _POST
> )
>
> [_requestUri:protected] => /
> [_baseUrl:protected] =>
> [_basePath:protected] =>
> [_pathInfo:protected] => /
> [_params:protected] => Array
> (
> [controller] => index
> [action] => index
> [module] => Kunba
> )
>
> [_aliases:protected] => Array
> (
> )
>
> [_dispatched:protected] => 1
> [_module:protected] => Kunba
> [_moduleKey:protected] => module
> [_controller:protected] => index
> [_controllerKey:protected] =>
> controller
> [_action:protected] => index
> [_actionKey:protected] => action
> )
>
> [1] =>
> Zend_Controller_Response_Http Object
> (
> [_body:protected] => Array
> (
> )
>
> [_exceptions:protected] => Array
> (
> )
>
> [_headers:protected] => Array
> (
> )
>
> [_headersRaw:protected] => Array
> (
> )
>
>
> [_httpResponseCode:protected] =>
> 200
> [_isRedirect:protected] =>
> [_renderExceptions:protected] =>
> [headersSentThrowsException] => 1
> )
>
> )
>
> )
>
> [13] => Array
> (
> [file] => /var/www/tracking/trunk/framwork/
> _projects_/Kunba/Bootstrap.php
> [line] => 436
> [function] => dispatch
> [class] => Zend_Controller_Front
> [type] => ->
> [args] => Array
> (
> )
>
> )
>
> [14] => Array
> (
> [file] => /var/www/tracking/trunk/library/
> ZendFramework-1.8.0b1/library/Zend/Application.php
> [line] => 302
> [function] => run
> [class] => Kunba_Bootstrap
> [type] => ->
> [args] => Array
> (
> )
>
> )
>
> [15] => Array
> (
> [file] => /var/www/tracking/trunk/framwork/
> index.php
> [line] => 149
> [function] => run
> [class] => Zend_Application
> [type] => ->
> [args] => Array
> (
> )
>
> )
>
> )
>
> )
> --
>
>
> Thanks a lot
>
> Marcel Alburg
>

Re: [fw-mvc] dijit.byId issue for Zend_Dojo RadioButton

2009/4/29 Kostyantyn Shakhov <kshakhov@gmail.com>
There are RadioButton and CurrencyTextBox on the page and I'm trying
to disable them but dijit.byId works fine for the CurrencyTextBox and
returns undefined for the RadioButton.

 This is correct because Dom id must be unique, and the radio button are more than one. A bunch of ids, that starts with the id you pass, is used, see the generated markup.


--
Giorgio Sironi
Piccolo Principe & Ossigeno Scripter
http://ossigeno.sourceforge.net

Fwd: [fw-mvc] A view helper that needs resources


2009/4/30 Jeff Carouth <jcarouth@tamu.edu>

What I would like to do is to get a configuration object (that is created during bootstrapping) into the view helper that holds the credentials, etc. for the Twitter service model _without_ stuffing it into the Registry.


What I do now when I have a dependency in a view helper is to follow the convention of returning the view helper when you call his method:
class My_View_Helper_Sample extends...
{
    public function sample($arg1 = null, $arg2 = null)
    {
        if (!func_get_args()) {
            return $this;
        }
    }
}
In the bootstrap I grab the view object when I setup the layout and request the view helper, that is created from the view. Then I call setXXXX() on it passing my config.
Since setting configuration for all helpers that may not be used is wasteful, I have a single View_Helper_Info that holds the configuration for the application. Other helpers call $this->view->info('configurationParameterName');


--
Giorgio Sironi
Piccolo Principe & Ossigeno Scripter
http://ossigeno.sourceforge.net

Re: [fw-mvc] Action ContextSwitch

Try setting the request's format parameter in your controller's preDispatch() hook:

$this->_request->setParam('format', 'xml');

-Hector


On Wed, Apr 29, 2009 at 11:48 PM, K.L. <coviex@gmail.com> wrote:
Hi!

Please, help to get idea of contexts.
There are questons I cannot find answers by now.
Is there a way to hint context (xml, for example) without explicitly
putting format var into request?
How to set exclusive context for an action (the way that all requests
to that particular action will be processed only in context specified,
without any hints)?

Regards,
Kostya


2009年4月29日星期三

[fw-mvc] Action ContextSwitch

Hi!

Please, help to get idea of contexts.
There are questons I cannot find answers by now.
Is there a way to hint context (xml, for example) without explicitly
putting format var into request?
How to set exclusive context for an action (the way that all requests
to that particular action will be processed only in context specified,
without any hints)?

Regards,
Kostya

[fw-mvc] A view helper that needs resources

In attempting to be a "purist" of sorts in terms of not introducing unnecessary dependencies in my code, I am attempting to use a view helper to access a model and bring in the data. For a simple example, I have a model, Model_Twitter, which is essentially a wrapper for the Zend_Service_Twitter client:


class Model_Twitter

{

    protected $_service = null;


    public function fetchLatestTweets($num = 10)

    {

        return $this->getService()->status->userTimeline(array('count' => $num));

    }

}


Obviously a significant—and irrelevant—amount of the model has been snipped for brevity.


To access the Twitter updates in a view I create a view helper.


class Zend_View_Helper_LatestTweets extends Zend_View_Helper_Abstract

{

    public function latestTweets($count) {

        //here is the problem I am trying to solve

        $twitterModel = new Model_Twitter($configurationAsHardcodedArray);

        $this->view->tweets = $twitterModel->fetchLatestTweets($count);


        return $this->view->render('sidebar/latest-tweets.phtml');

    }

}


What I would like to do is to get a configuration object (that is created during bootstrapping) into the view helper that holds the credentials, etc. for the Twitter service model _without_ stuffing it into the Registry. The solutions that come to mind are:


    1. Injecting the necessary resource—in this case the configuration object—into the view, but this smells horrible.

    2. Creating a view helper to access the configuration object. But if I can access the config object in one view helper, why don't I just give that same access to the current resource.

    3. Extending my view helpers from a base view helper that has a dependency container for such purposes.

    4. None of the above.

    5. All of the above.

    6. Some combination hereof.


What solution would you use? Am I making this harder than it should be?


Thank you for pointers and insight.


Regards,

- Jeff

Re: [fw-core] Zend Form and Input Filtering

Hmm.. good point. I've gone ahead and done that and works well. Seems like the NormalizedToLocalized and reverse filters aren't available in ZF 1.7, so went with the pregReplace.

Is it just me or are forms really flakey? I tried adding a GreaterThan validator in my ini config, but it refused to work. When I access an element ($form->elementName->getValue()) it tells me that I'm using a method on a non-object. I tried adding it programatically and it worked fine. Weird.

Here's what I've got:

elements.event_max_per_child.type                   = "text"
elements.event_max_per_child.options.label          = "Max Interviews Per Child"
elements.event_max_per_child.options.required       = true
elements.event_max_per_child.options.filters.int.filter = int

;Adding this one works:
;elements.event_max_per_child.options.validators.notempty.validator = "NotEmpty"

;I add these and the form dies
;elements.event_max_per_child.options.validators.greaterthan.validator = "GreaterThan'
;elements.event_max_per_child.options.validators.greaterthan.options.min = 1


In my form class's init() method:

 $this->getElement('event_max_per_child')
            ->addValidator('GreaterThan', false, array('min' => 1));

           
Any idea what I'm doing wrong?

Cheers,
David


Hector Virgen wrote:
I wouldn't say it's necessary, but it helps promote reuse. Otherwise you'll have to write that conversion in each of your view scripts that uses a date.

-Hector


On Tue, Apr 28, 2009 at 5:49 PM, David Muir <david@davidkmuir.com> wrote:
I'm aware of Matthew's articles. My question however was whether or not creating my own decorator is necessary in this case, and also whether the NormalizedToLocalized and vice versa filters are the ones I should be using. The documentation is a wee bit sparse for those particular filters.

David


Hector Virgen wrote:
Matthew wrote an excellent blog entry on this exact topic, you should check it out.


-Hector


On Tue, Apr 28, 2009 at 12:49 AM, David Muir <david@davidkmuir.com> wrote:
What's the best way to handle a time or date field?

At the moment, for dates I've added a pregReplace filter to the form element to swap from dd/mm/yyyy to yyyy-mm-dd.

Then in the view scrip, I have a second filter added to swap from yyyy-mm-dd to dd/mm/yyyy.

It works, but I'm not really happy with the code. I just noticed the NormalizedToLocalized and LocalizedToNormalized filters, which I'm assuming is what I should be using.

Is the cleanest way to deal with this be to create date and time elements together with their own custom decorators that apply the NormalizedToLocalized filter on output? I would have thought that this is such a common use-case that there would already have been something set up for this?

Cheers,
David





Re: [fw-auth] Zend_Auth_Adapter_Cas

Thanks!


Matthew Weier O'Phinney-3 wrote:
>
> -- gammamatrix <jeremy.postlethwaite@gmail.com> wrote
> (on Tuesday, 28 April 2009, 12:18 PM -0700):
>> I see that the Zend_Auth_Adapter_Cas proposal has stalled:
>>
>> http://framework.zend.com/wiki/pages/viewpage.action?pageId=43342
>>
>> I have created my own version of this class which is in use at UC Davis:
>> http://ucdavis.edu/
>>
>> The class is fully functioning with an example. It should be compatible
>> with
>> CAS 1, 2, and 3.
>>
>> I have submitted a CLA so I can post proposals, so I need to wait until I
>> get approved before I can contribute.
>
> Ask for community review of your proposal. You can do that on this list,
> the more popular fw-general list, or on the zf-contributors list. Be
> persistent, and try and get people to read the proposal and provide
> feedback.
>
> Once you have done so, and incorporated any pertinent feedback,
> re-parent the proposal as "ready for recommendation". At that time, the
> internal team will evaluate the proposal for inclusion within the
> framework.
>
> --
> Matthew Weier O'Phinney
> Project Lead | matthew@zend.com
> Zend Framework | http://framework.zend.com/
>
>

--
View this message in context: http://www.nabble.com/Zend_Auth_Adapter_Cas-tp23284242p23304513.html
Sent from the Zend Auth mailing list archive at Nabble.com.

[fw-mvc] DB transactions and Zend_Db_Table

I mostly use Zend_Db_Table to query and update rows in the database since it tends to simplify things due to being able to define relationships, primary keys, etc. Occasionally, I end up having to make calls to the DB adapter object for things like quoteInto, fetchPairs, etc.
 
Now if I want to lump multiple table updates into a transaction, the ZF docs show how to do this using the Adapter class. For example:
$db->beginTransaction();

try {
    // Attempt to execute one or more queries:
    $db->query(...);
    $db->query(...);
    $db->query(...);

    // If all succeed, commit the transaction and all changes
    // are committed at once.
    $db->commit();

} catch (exception $e) {
    $tableA->getAdapter()->rollback();
    ..........


}
Should I take that to mean that this is the only way to implement transactions? I know I can indirectly access adapter methods with $myTable->getAdapter()->method() calls, but will the following work?
$tableA->getAdapter()->beginTransaction();

try {
    // Attempt to execute one or more queries:
    $rowA = $tableA->fetch(...);
    $rowB = $tableB->fetch(...);
    //do stuff to each row object;
    $rowA->save();
    $rowB->save();

    // If all succeed, commit the transaction and all changes
    // are committed at once.
    $tableA->getAdapter()->commit();
} catch (exception $e) {
    $tableA->getAdapter()->rollback();
    ..........


}

Seth Atkins

Re: [fw-auth] blocking users

Could you please send me the increment code, it increments in the first time
and then stops i guess there is something wrong. This is my Code
$this->view->message = 'Login failed you probably enterd your user name or
password Incorrectly';
$db = Zend_Registry::get('db');
$i=0;
$i+=+1;
$data = array( 'failed_logins' => $i);
$n = $db->update('account478', $data, "username='$uname'");
$this->view->form = $form;
$form->populate($Data);

please help me


Hector Virgen wrote:
>
> If you're using database authentication, take a look at this page to see
> how
> you can add extra conditionals to the adapter:
> http://framework.zend.com/manual/en/zend.auth.adapter.dbtable.html#zend.auth.adapter.dbtable.advanced.advanced_usage
>
> If you want to prevent login after 3 unsuccessful attempts, you can add a
> "failed_login_attempts" field to your users table, and increment the value
> each time the authentication fails.
>
> -Hector
>
>
> On Wed, Apr 15, 2009 at 2:07 PM, Ralph Schindler
> <ralph.schindler@zend.com>wrote:
>
>> Attempting to log in with bad credentials 3 times?
>>
>> Or simply only allowing them to log in 3 times per account?
>>
>> -ralph
>>
>>
>> Doood wrote:
>>
>>> hi, I want to know how to block an account after logining in for more
>>> than
>>> 3
>>> times using the zend framework.
>>>
>>> thanks in advance
>>>
>>
>>
>
>

--
View this message in context: http://www.nabble.com/blocking-users-tp23067116p23302610.html
Sent from the Zend Auth mailing list archive at Nabble.com.

Re: [fw-core] Zend Form and Input Filtering

I wouldn't say it's necessary, but it helps promote reuse. Otherwise you'll have to write that conversion in each of your view scripts that uses a date.

-Hector


On Tue, Apr 28, 2009 at 5:49 PM, David Muir <david@davidkmuir.com> wrote:
I'm aware of Matthew's articles. My question however was whether or not creating my own decorator is necessary in this case, and also whether the NormalizedToLocalized and vice versa filters are the ones I should be using. The documentation is a wee bit sparse for those particular filters.

David


Hector Virgen wrote:
Matthew wrote an excellent blog entry on this exact topic, you should check it out.


-Hector


On Tue, Apr 28, 2009 at 12:49 AM, David Muir <david@davidkmuir.com> wrote:
What's the best way to handle a time or date field?

At the moment, for dates I've added a pregReplace filter to the form element to swap from dd/mm/yyyy to yyyy-mm-dd.

Then in the view scrip, I have a second filter added to swap from yyyy-mm-dd to dd/mm/yyyy.

It works, but I'm not really happy with the code. I just noticed the NormalizedToLocalized and LocalizedToNormalized filters, which I'm assuming is what I should be using.

Is the cleanest way to deal with this be to create date and time elements together with their own custom decorators that apply the NormalizedToLocalized filter on output? I would have thought that this is such a common use-case that there would already have been something set up for this?

Cheers,
David




Re: [fw-mvc] How do I customize the escape() function for HTML rendering?

Thanks for your explanation. Scope and targeting is one of those things that
dogs me. I changed the var in the foreach to row, but you also have to use
it in each variable assignment. Your example has '$page_id =
$this->escape($text->page);'.

Here's what it looks like now:

foreach($this->text as $row) :
if ($this->escape($row->page) == $this->escape($this->id)) {
$page_id = $row->page;
$content1 = $row->content1;
$content2 = $row->content2;
}
endforeach;

You don't need to escape with each var assignment, so you can just go ahead
and <?php print $content1; ?>, and the html renders fine.

I hope this helps out others newbies like me!
--
View this message in context: http://www.nabble.com/How-do-I-customize-the-escape%28%29-function-for-HTML-rendering--tp23283430p23295981.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Res: [fw-db] Problem with toArray logging a fatal error to the screen instead allowing catch to get it.

You need to test if found results

Try this:


try {
$found = $this->article->find($id);
if ($found->count()) {
$this->view->mainArticle = $found->current()->toArray();
}
}
catch( Exception $e )
{
Zend_Registry::get('logger')->err($e->getMessage());
Zend_Registry::get('logger')->notice('User tried to do somthing in articles that was not allowed');
$this->_helper->redirector('index','index');
}

----- Mensagem original ----
De: Mr. Eric Eugene Naujock <naujocke@mac-cafe.com>
Para: fw-db@lists.zend.com
Enviadas: Quarta-feira, 29 de Abril de 2009 10:25:41
Assunto: [fw-db] Problem with toArray logging a fatal error to the screen instead allowing catch to get it.

I have a function that calls a table object to return a rowset. The code results in a fatal error thrown up on the screen instead of allowing me to gracefully handle it.

Below is a code example.

The variable $id is a umber for the article I am trying to pull up.
if $id is a number that there is no record for in the database then it will crash.

try {
$this->view->mainArticle = $this->article->find($id)->current()->toArray();
}
catch( Exception $e )
{
Zend_Registry::get('logger')->err($e->getMessage());
Zend_Registry::get('logger')->notice('User tried to do somthing in articles that was not allowed');
$this->_helper->redirector('index','index');
}

The error I was getting is Fatal error: Call to a member function toArray() on a non-object in. My catch code is not ever getting a chance to gracefully handle the problem.

I read thourgh the documentation the result is supposed to be a rowset object even if the query fails. But the toArray() causes the fatal error.

Veja quais são os assuntos do momento no Yahoo! +Buscados
http://br.maisbuscados.yahoo.com

[fw-db] Problem with toArray logging a fatal error to the screen instead allowing catch to get it.

I have a function that calls a table object to return a rowset. The
code results in a fatal error thrown up on the screen instead of
allowing me to gracefully handle it.

Below is a code example.

The variable $id is a umber for the article I am trying to pull up.
if $id is a number that there is no record for in the database then it
will crash.

try {
$this->view->mainArticle = $this->article->find($id)->current()-
>toArray();
}
catch( Exception $e )
{
Zend_Registry::get('logger')->err($e->getMessage());
Zend_Registry::get('logger')->notice('User tried to do somthing
in articles that was not allowed');
$this->_helper->redirector('index','index');
}

The error I was getting is Fatal error: Call to a member function
toArray() on a non-object in. My catch code is not ever getting a
chance to gracefully handle the problem.

I read thourgh the documentation the result is supposed to be a rowset
object even if the query fails. But the toArray() causes the fatal
error.

Re: [fw-db] Models in Modular Application

Cristian Bichis schrieb:
> Ok, i found out why the modules bootstrappes are called.
>
> Seems order of calling is:
> - app bootstrap
> - modules bootstrap
>
> So if we use a module resource Admin_Model_BlaBla by example on app
> bootstrap obviously the application is failing...

I hope, I understand.
If you want to use something in application bootstrap, that is
initialized in a module bootstrap, you can bootstrap the modules-resources.
$this->bootstrap('modules');
It will initialize all module bootstraps including the resource loaders.

--
Sebastian Krebs
http://www.kingcrunch2000.de
PGP public key for encryption
http://kingcrunch2000.de/public/0x44291B2B-pub.asc

Re: [fw-mvc] How do I customize the escape() function for HTML rendering?

On 29 Apr 2009, at 12:41, bentobenji wrote:

>
> Removing '$this->' from the data path did indeed work. However,
> someone
> gave me another the solution on another forum, which I will reveal
> below.
>
> In the interest of helping any other readers of the forum however,
> I'll give
> you the error message I was receiving to help clear it up. If I keep
> '$this' in the data path, I get this error:
>
> Catchable fatal error: Object of class Zend_Db_Table_Row could not be
> converted to string in
> /Users/me/Sites/njaimh-zf/application/views/scripts/index/
> index.phtml on
> line 15
>
> Like I said , saying '$text->content2;' insead of '$this->$text-
> >content2;'
> DOES work.

That's because you are referencing something different.

You assigned the result set of your database query, which is an
instance of Zend_Db_Table_Rowset to the view as a the variable called
"text" in your controller using $this->view->text = $text->fetchAll();

This means that within a view script, such as index.phtml, the
resultset is accessible as $this->text. This is because when you are
in the view script, $this is a reference to the view object.

Now, your foreach loop statement is: foreach($this->text as $text)
This line creates a local variable called $text which is an instance
of a Zend_Db_Table_Row. i.e. you have used the same variable name
"text" for two different types of object.

You'd be better to change your foreach to something like:

foreach($this->text as $row) :
if ($this->escape($row->page) == $this->escape($this->id)) {
$page_id = $row->escape($text->page);
$content1 = $row->escape($text->content1);
$content2 = $row->escape($text->content2);
}
endforeach;

This way it is clear that $this->text is the set of rows and $row is
the particular row you are operating on.

However, if you really want to just just get one row, then use
fetchRow() in your controller rather than fetchAll().


> I guess somehow that bypasses the view engine running off of the index
> controller but I don't know how.

No. It's nothing to do with that and everything to do with which
variable you are using.


> The other solution I got is just regular php. It's in the echo/print
> function:
>
> print html_entity_decode($content2);
>
> I guess I'll stick with this one since it apparently keeps the escape
> running, which is more secure I suppose.

It is pointless to encode and then decode.

Regards,

Rob...

--
Rob Allen
Zend Framework Tutorial: http://akrabat.com/zft
Author of Zend Framework in Action: http://www.zendframeworkinaction.com

Re: [fw-db] Zend_Db_Adapter_Db2 and Zend_Db_Adapter_Pdo_Ibm set AUTHORIZATION param

I've registered nothing with the CLI...

However, with that parameter the connection will work, so I think that
AT LEAST within Zend Framework I should be able to set that option.


Il giorno 23/apr/09, alle ore 12:02, Christian Welzel ha scritto:

> Emanuele Deserti schrieb:
>
> > What do you think?
>
> You can try to use a database connection that you registered using
> the CLI.
>
>
> --
> MfG, Christian Welzel
>
> GPG-Key: http://www.camlann.de/key.asc
> Fingerprint: 4F50 19BF 3346 36A6 CFA9 DBDC C268 6D24 70A1 AD15
>

---
Emanuele Deserti
Netwing S.r.l.
<emanuele.deserti@netwing.it>
Tel. 0532-1915183
http://www.netwing.it

Re: [fw-mvc] How do I customize the escape() function for HTML rendering?

On 29 Apr 2009, at 12:41, bentobenji wrote:

> Anyway, if you have an explanation
> to why removing '$this->' does the trick, I'd love to know.
>
> Your help is appreciated greatly!!

Because your $text variable is in the local scope of the foreach loop
and is not a member property of the view.

Paul

Re: [fw-mvc] How do I customize the escape() function for HTML rendering?

Removing '$this->' from the data path did indeed work. However, someone
gave me another the solution on another forum, which I will reveal below.

In the interest of helping any other readers of the forum however, I'll give
you the error message I was receiving to help clear it up. If I keep
'$this' in the data path, I get this error:

Catchable fatal error: Object of class Zend_Db_Table_Row could not be
converted to string in
/Users/me/Sites/njaimh-zf/application/views/scripts/index/index.phtml on
line 15

Like I said , saying '$text->content2;' insead of '$this->$text->content2;'
DOES work.

I guess somehow that bypasses the view engine running off of the index
controller but I don't know how.

The other solution I got is just regular php. It's in the echo/print
function:

print html_entity_decode($content2);

I guess I'll stick with this one since it apparently keeps the escape
running, which is more secure I suppose. Anyway, if you have an explanation
to why removing '$this->' does the trick, I'd love to know.

Your help is appreciated greatly!!

--
View this message in context: http://www.nabble.com/How-do-I-customize-the-escape%28%29-function-for-HTML-rendering--tp23283430p23295601.html
Sent from the Zend MVC mailing list archive at Nabble.com.