2008年8月27日星期三

Re: [fw-mvc] viewHelper only decorator for Zend_Form_Element_MultiCheckbox

-- Václav Vaník <vanik@walk.cz> wrote
(on Wednesday, 27 August 2008, 06:41 AM -0700):
> I want to render multicheckbox with view helper only (no label decorator)
>
> my form is:
>
> $form = new Zend_Form();
> $multi = $form->createElement('multiCheckbox', 'foo');
> $form->addElement($multi)->setElementDecorators(array('ViewHelper'));
>
> and rendered checkbox is inside label
>
> I tried:
>
> $multi = $form->createElement('multiCheckbox', 'foo');
> $multi->setDecorators(array('ViewHelper'));
>
> but result is with label :(

MultiCheckbox generates labels for each checkbox -- this is not part of
decoration, but generated via the view helper itself.

You can create your own MultiCheckbox view helper to drop in as a
replacement if you need to customize the HTML output.

--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/

Re: [fw-db] Update with where clause!!

The other option i think i would use is to have a query function with the
sql query in it. Then i dont have to worry about bugs with arrays and stuff

so something like
$sql = $db->quoteInto('Update MemEvents SET IsActive= 1 WHERE EventID
=?',$requestEvent ).$db->quoteInto('AND MemberID=?',$requestMember);
$query = $db->query($sql);
...

I definitely would prefer this going the PDO route...

Bill Karwin wrote:
>
>
>
> dele454 wrote:
>>
>> Hi am trying to use the update() of the Zend_Db class for 2 conditions
>> that must be true for the update to take place:
>>
>>
>> $where[] = "EventID = ' ". $requestEvent ."'";
>> $where[] = "MemberID = ' ". $requestMember ."'";
>> $db->update('memevents', $updateColumn,$where);
>>
>> Wherever i run this code my view appears blank. The only thing that makes
>> this code different from that in the ZF doc is that i am inserting
>> parameters from the URL into mine.
>>
>> I dont know why this isnt working strangely when i comment out on of the
>> array declarations then the code runs. :( But i need both conditions!!
>>
>>
>>
>
> Unfortunately not all methods consistently support an array for the
> where-clause parameter.
> This is a long-desired enhancement and there is a bug logged for it:
> http://framework.zend.com/issues/browse/ZF-1726
>
> You can work around this by joining your array into a string:
>
> $where[] = "EventID = ' ". $requestEvent ."'";
> $where[] = "MemberID = ' ". $requestMember ."'";
> $db->update('memevents', $updateColumn, join(' AND ', $where));
>
> Be careful to put spaces in the ' AND ' string, and use parentheses to
> clarify precedence if each term contains OR expressions.
>
> Regards,
> Bill Karwin
>


-----
dee
--
View this message in context: http://www.nabble.com/Update-with-where-clause%21%21-tp19180609p19181511.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-db] Update with where clause!!

Thanks Bill i knew you would have an answer to it :)

dele454 wrote:
>
> Hi am trying to use the update() of the Zend_Db class for 2 conditions
> that must be true for the update to take place:
>
>
> $where[] = "EventID = ' ". $requestEvent ."'";
> $where[] = "MemberID = ' ". $requestMember ."'";
> $db->update('memevents', $updateColumn,$where);
>
> Wherever i run this code my view appears blank. The only thing that makes
> this code different from that in the ZF doc is that i am inserting
> parameters from the URL into mine.
>
> I dont know why this isnt working strangely when i comment out on of the
> array declarations then the code runs. :( But i need both conditions!!
>
>
>


-----
dee
--
View this message in context: http://www.nabble.com/Update-with-where-clause%21%21-tp19180609p19181377.html
Sent from the Zend DB mailing list archive at Nabble.com.

[fw-auth] LDAP - following referrals

Hello,

I have an issue with Zend_Auth_Adapter_Ldap..

A bit of backgroud...

Zend Framework version 1.5.3
php5 -v : PHP 5.2.5 with Suhosin-Patch 0.9.6.2  Zend Engine v2.2.0
OS: SLES 10 SP2

My site has multiple LDAP servers.  Some of these servers can potentially return a "Referral" when searching for specific data for a user.
For example (using ldapsearch):

ldapsearch -b -o=myorg -h ldap-server1 -Z -x '(uid=someuser)' dn
this returns:

search: 3
result: 10 Referral
ref: ldaps://ldap-server2/o=myorg
ref: ldaps://ldap-server3/o=myorg
ref: ldaps://ldap-server4/o=myorg

If I add the -C option to above, I will get the dn for "someuser", cn=someuser,o=myorg

When using Zend_Auth_Adapter_Ldap and following the basic instructions at http://framework.zend.com/manual/en/zend.auth.adapter.ldap.html for authentication, when I look at the /tmp/ldap.log file, I see the following:

<date> DEBUG (7): Ldap: 2: someuser authentication failed: 0x20: Referral: (uid=someuser)

Is there some way to have Zend_Auth_Adapter_Ldap follow the Referral?

I have tried the following with no success:

$adapter = new Zend_Auth_Adapter_Ldap($options, $username, $password);
ldap_set_options($adapter->getLdap()->getResource(), LDAP_OPT_REFERRALS, 1);
$result = $auth->authenicate($adapter)

Note, my Zend_Config_Ini configuration for contains the following

ldap.server1.host = ldap-server1
ldap.server1.useSsl = true
ldap.server1.baseDn = o=myorg
ldap.server1.accountFilterFormat = "(uid=%s)"
ldap.server1.bindRequireDn = true

Is there a way to make the adapter follow the "Referral"?  Is there something that need to be configured externally?

Thanks,
Mike

[fw-mvc] viewHelper only decorator for Zend_Form_Element_MultiCheckbox

Hi,

I want to render multicheckbox with view helper only (no label decorator)

my form is:

$form = new Zend_Form();
$multi = $form->createElement('multiCheckbox', 'foo');
$form->addElement($multi)->setElementDecorators(array('ViewHelper'));

and rendered checkbox is inside label

I tried:

$multi = $form->createElement('multiCheckbox', 'foo');
$multi->setDecorators(array('ViewHelper'));

but result is with label :(

I have ZF 1.6RC2
--
View this message in context: http://www.nabble.com/viewHelper-only-decorator-for-Zend_Form_Element_MultiCheckbox-tp19181211p19181211.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-db] Update with where clause!!

dele454 wrote:
>
> Hi am trying to use the update() of the Zend_Db class for 2 conditions
> that must be true for the update to take place:
>
>
> $where[] = "EventID = ' ". $requestEvent ."'";
> $where[] = "MemberID = ' ". $requestMember ."'";
> $db->update('memevents', $updateColumn,$where);
>
> Wherever i run this code my view appears blank. The only thing that makes
> this code different from that in the ZF doc is that i am inserting
> parameters from the URL into mine.
>
> I dont know why this isnt working strangely when i comment out on of the
> array declarations then the code runs. :( But i need both conditions!!
>
>
>

Unfortunately not all methods consistently support an array for the
where-clause parameter.
This is a long-desired enhancement and there is a bug logged for it:
http://framework.zend.com/issues/browse/ZF-1726

You can work around this by joining your array into a string:

$where[] = "EventID = ' ". $requestEvent ."'";
$where[] = "MemberID = ' ". $requestMember ."'";
$db->update('memevents', $updateColumn, join(' AND ', $where));

Be careful to put spaces in the ' AND ' string, and use parentheses to
clarify precedence if each term contains OR expressions.

Regards,
Bill Karwin
--
View this message in context: http://www.nabble.com/Update-with-where-clause%21%21-tp19180609p19181103.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-db] zend_db_table_row and quoting

tony stamp wrote:
>
> Hello
>
> Just a quick question - when updating a row in a database, i usually do:
>
> $query = "update foo set bar = ?, baz = ?, goon = ?";
> $sth->execute($query, array('a', 'b', 'c');
>
> where i know that the db abstraction layer will apply quoting to make the
> values safe.
>

You have misunderstood. The code you show does not do quoting, it treats
the values as query parameters. Parameters are not interpolated into the
SQL string, so parameters don't require quoting.

It's a bit confusing, because methods like quoteInto() use the ? character
as an interpolation placeholder, while SQL also uses ? as a parameter
placeholder.


tony stamp wrote:
>
> ... will quoting also be applied to the row before saving, or is that the
> responsibility of the row to implement ie subclassing and performing
> validation on the properties before an update?
>

The $row->save() method uses $db->update() internally, so it gains the same
benefits of query parameters. It does use quoting for the WHERE clause of
the update, but it performs quoting for you in that case.

One exception: if you have set one of the row fields to a Zend_Db_Expr, you
are responsible for quoting. For example, suppose you want to update the
row but make sure a very long string is shortened instead of exceeding the
field length in the database, you can use a SQL expression like this:

$row->name = $name;
$row->surname = new Zend_Db_Expr($db->quoteInto('SUBSTRING(?, 0, 10)',
$surname));
$row->save();

You have to use Zend_Db_Expr because otherwise the entire expression
starting with 'SUBSTRING(...' will be treated as the new surname. But once
you use Zend_Db_Expr, the update will interpolate it into the SQL statement
instead of using a query parameter. Thus you are responsible for quoting
any strings you interpolate into the expression.

The result will be SQL:

UPDATE tablename
SET name = ?, -- note query parameter placeholder
surname = SUBSTRING('O\'Reilly', 0, 10) -- note quoting and escaping has
been done
WHERE primarykey = 1234;

Then it executes the query, passing $name as the sole query parameter to
execute().

Regards,
Bill Karwin
--
View this message in context: http://www.nabble.com/zend_db_table_row-and-quoting-tp19177390p19180753.html
Sent from the Zend DB mailing list archive at Nabble.com.