2010年6月29日星期二

Re: [fw-db] raw SQL to Zend_Db_Select ?

Thanks guys, this is helpful.

On Mon, Jun 28, 2010 at 2:37 PM, Bill Karwin <bill@karwin.com> wrote:

By the way, I would think if you have a fully-formed SELECT query, there's little reason to convert it to a Zend_Db_Select object.  I suppose this gives you the ability to add more joins or conditions or whatever, but that seems like a pretty rare use.

There's a helluva lot of joining and some conditional logic in the basic query and I want to be able to add more WHERE based on user input. I think it's an ideal scenario for a private|protected method or variable to provide you with a Zend_Db_Select for further refinement. There's also likely to be Zend_Paginator involved, which plays so nicely with Zend_Db_Select.
 

There are no practical limits on how complicated an expression you can represent in a Zend_Db_Expr object.  


Cool. Thanks again.


--
Support real health care reform:
http://phimg.org/

--
David Mintz
http://davidmintz.org/


2010年6月28日星期一

Re: [fw-gdata] GData multi domain/user alias support

I don't think so. I've put up a fix for including version 2 of the API to make use of the group and owner/member relationship of a group months ago and it has never progressed since then. Furthermore the Multiple Domains and Aliases stuff are experimental so they are all the more unlikely.

On 28 June 2010 15:06, Rob Gillan <rob@mosais.com> wrote:

Hi,

I was wondering if anyone was working on support for the recently introduced
enhancements to the provisioning API for Google Apps, namely Users in
Multiple Domains and User Aliases in Multiple Domains.

Thanks
Rob

-----
Rob Gillan
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/GData-multi-domain-user-alias-support-tp2270541p2270541.html
Sent from the Zend gdata mailing list archive at Nabble.com.

Re: [fw-db] raw SQL to Zend_Db_Select ?

SQL is a context-free grammar.  To transform SQL statements into another representation you would need a non-deterministic parser of some kind.  Think of yacc or bison for C, or ANTLR for Java.

Lime (http://sourceforge.net/projects/lime-php/) is a parser generator written in PHP, and which generates parser code that is also PHP code.  But Lime appears to be abandonware, not having been updated since May 2008.  The docs are pretty much non-existent.

By the way, I would think if you have a fully-formed SELECT query, there's little reason to convert it to a Zend_Db_Select object.  I suppose this gives you the ability to add more joins or conditions or whatever, but that seems like a pretty rare use.

There are no practical limits on how complicated an expression you can represent in a Zend_Db_Expr object.  

Regards,
Bill Karwin

On Jun 28, 2010, at 9:21 AM, David Mintz wrote:

Before I even start trying, I am wondering how difficult it is to re-fashion an elaborate SELECT query (MySQL) into a Zend_Db_Select object. There are things like IF() containing nested CASE statements. Are there  limits, for example, on how complicated a Zend_Db_Expr() can get?

I guess the other option is to create a view. The point is to have all the basic heavy lifting cleanly encapsulated and add more WHERE clauses programmatically.



--
Support real health care reform:
http://phimg.org/

--
David Mintz
http://davidmintz.org/



Re: [fw-db] raw SQL to Zend_Db_Select ?

AFAIK there are no limits as to how complicated a Zend_Db_Expr object can be. All it does is it contains a substring of the SQL query. That substring could be anything. When $db->quote() encounters the Zend_Db_Expr object, it simply pulls the string out and returns it unchanged (i.e. unquoted).

It's possible to build very complex SQL queries using Zend_Db_Select. If you run into any specific problems feel free to post back here.

--
Hector


On Mon, Jun 28, 2010 at 9:21 AM, David Mintz <david@davidmintz.org> wrote:
Before I even start trying, I am wondering how difficult it is to re-fashion an elaborate SELECT query (MySQL) into a Zend_Db_Select object. There are things like IF() containing nested CASE statements. Are there  limits, for example, on how complicated a Zend_Db_Expr() can get?

I guess the other option is to create a view. The point is to have all the basic heavy lifting cleanly encapsulated and add more WHERE clauses programmatically.



--
Support real health care reform:
http://phimg.org/

--
David Mintz
http://davidmintz.org/



[fw-db] raw SQL to Zend_Db_Select ?

Before I even start trying, I am wondering how difficult it is to re-fashion an elaborate SELECT query (MySQL) into a Zend_Db_Select object. There are things like IF() containing nested CASE statements. Are there  limits, for example, on how complicated a Zend_Db_Expr() can get?

I guess the other option is to create a view. The point is to have all the basic heavy lifting cleanly encapsulated and add more WHERE clauses programmatically.



--
Support real health care reform:
http://phimg.org/

--
David Mintz
http://davidmintz.org/


[fw-gdata] GData multi domain/user alias support

Hi,

I was wondering if anyone was working on support for the recently introduced
enhancements to the provisioning API for Google Apps, namely Users in
Multiple Domains and User Aliases in Multiple Domains.

Thanks
Rob

-----
Rob Gillan
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/GData-multi-domain-user-alias-support-tp2270541p2270541.html
Sent from the Zend gdata mailing list archive at Nabble.com.

2010年6月26日星期六

[fw-gdata] Re: Youtube - Retrieving feed from a single video by URL

radw_row wrote:
>
>
> $url =
> 'http://gdata.youtube.com/feeds/api/videos/<yt:videoid>LWeiTlDrI28</yt:videoid>';
> //error here
>
>

I think that should be this:

$url = 'http://gdata.youtube.com/feeds/api/videos/LWeiTlDrI28';
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Youtube-Retrieving-feed-from-a-single-video-by-URL-tp1569922p2269690.html
Sent from the Zend gdata mailing list archive at Nabble.com.

[fw-mvc] problem in zend_soap_client

hi guys

my code is  :

$soapZarinPal = new Zend_Soap_Client("http://www.zarinpal.com/WebserviceGateway/wsdl", array('encoding'=>'UTF-8'));
            $configOBJ = new Config();
            $configData = $configOBJ->getConfigs();
            $siteURLcallBack = $configData[0]['siteurl']."/account/verifypayment";
          
            $res = $soapZarinPal->PaymentRequest('mypinnumberin  zarinpal.com', '1000', $siteURLcallBack, "a");
            $this->_redirect("https://www.zarinpal.com/users/pay_invoice/" .$res);

and it throws this exception :

SoapFault: Operation '' is not defined in the WSDL for this service

thrown in C:\Users\Sina Miandashti\Desktop\xampplite\xampplite\htdocs\vando\library\Zend\Soap\Client.php on line 1118

Call Stack

  1. SoapClient->__soapCall()
    in C:\Users\Sina Miandashti\Desktop\xampplite\xampplite\htdocs\vando\library\Zend\Soap\Client.php on line 1118


--
________________
Sincerely
Sina Miandashti
MuSicBasE.ir & InvisionPower.ir Admin

2010年6月25日星期五

Re: [fw-mvc] email replies?

i cant find where it support pipe emails to script (cPanel function)

On Sat, Feb 6, 2010 at 4:44 PM, Pieter Kokx <pieter@kokx.nl> wrote:
You should take a look at the Zend_Mail documentation:

http://framework.zend.com/manual/en/zend.mail.read.html

--
Best Regards,

Pieter Kokx
PHP Developer
Zend Framework developer



sina miandashti schreef:
> hi
>
> i dont know any thing about handling email replies with php
>
> is it possible with zend frame work?
>
> give me solution plz
>
>




--
________________
Sincerely
Sina Miandashti
MuSicBasE.ir & InvisionPower.ir Admin

Re: [fw-auth] Zend_ACl

Hi,

In your blog you have mentioned this way

"

Last but not least we define our access rules:

1. A subscriber has access to all articles
2. A visitor has access to all free articles
3. A visitor has access to all non-free articles that he paid for

"

Then How about some other new role like subscriber giving access to known visitors with some privileges how can this be handeled.


On Mon, Jun 21, 2010 at 6:01 PM, Jeroen Keppens <jeroen.keppens@gmail.com> wrote:
Hi Trinath,

I wrote a blog post on ACL / models a couple of weeks ago. It's not 100% what you are looking for I think, but it might get you on route to a solution. It shows how you can use ACL in your models, perform checks and in the case of the article make sure the visitor has access on a content-specific item (i.e. not just on "Article" but on a specific article).

http://www.amazium.com/blog/content-driven-access-control-with-zend-acl

Instead of having "device management" as a resource, you could have "device" as a resource. Your device model would then implement the Resource interface. Your actions add, edit, delete, view etc... would be privileges. You can then check in your service layer (or controller) if a User (implementing role) has edit (privilege) access on Device (implementing a resource) and then call the edit function on your module (or something similar).

Hope this is a good start for you.

wkr,
Jeroen

On 21 Jun 2010, at 13:51, Trinath Somanchi wrote:

> Hi All,
>
> I'm new to Zend_Acl and interested in knowing how it will be suiting for my ACL structure.
>
> The following are the Roles:
>
> [1] Super User
> [2] Administrator
> [3] Manager
> [4] Guest
>
> The following are the Resources.
>
> [1] Device Management
> [2] Application Management
> [3] Object Management
> [4] User Management
> [5] Server Administration
>
> And the following are the Rules.
>
> [1] Add/Edit/Delete User
> [2] Add/Edit/Delete Device
> [3] Allow access to Device for other users.
> [4] Add/Edit/Delete Application
> [5] Allow access to Application for other users.
> [6] Add/Edit/Delete Objects
> [7] Allow access to Objects for other users.
> [8] Do Database Backup
> [9] Archive and Restore Database
>
> All the above rules are assigned to ROLES. And Users are assigned to Roles.
>
> As it is clear, Any user having a Role can perform the tasks in the server/system as applicable with respect to the Rules present in the roles.
>
> Now, A user can ADD/EDIT/DELETE Devices, Application and Objects. Also I have another ACL for Devices, Applications and objects.
>
> User Bob (holds manager role) who owns a Device can create Applications for the device and objects for the application.
>
> Now Bob wants user John to have privilege to access for all objects under  Application "ABC" under Device "DD1".
>
> Also Bob wants to provide access for using objects "OBJ-1" and "OBJ-3" which he owned under Application "DEF" under Device "DD1".
>
> And also Bob wants to add another user "Jane" and wants to grant privilege for accessing Objects "OBJ-5" under Application "GHI" and all objects under Application "DHG" which under Device "DD1".
>
> The achieve the above use case, Bob must have Rules assigned to his role mentioned above from [1] to [7].
>
> Pleas help me on how Zend_ACL can be user for achieving this ACL.
>
> Thanks in advance.
>
>
> --
> Regards,
> ----------------------------------------------
> Trinath Somanchi,




--
Regards,
----------------------------------------------
Trinath Somanchi,

2010年6月24日星期四

Re: [fw-mvc] Extending navigation view helpers

Oops! The correct application.ini change should be like this:

; View
resources.view.encoding = "UTF-8"
resources.view.basePath = APPLICATION_PATH "/views"
resources.view.helperPath.Zend_View_Helper_Navigation = "Zend/View/Helper/Navigation"
resources.view.helperPath.Default_View_Helper = APPLICATION_PATH "/views/helpers"

--
Hector


On Thu, Jun 24, 2010 at 9:36 AM, Hector Virgen <djvirgen@gmail.com> wrote:
Thanks Jurian. I like your suggestion, but maybe a simpler solution would be to place the ZF nav helper path closer to the beginning of the stack instead of the end. The final stack would go from looking like this:

Zend_View_Helper => Zend/View/Helper
My_View_Helper => My/View/Helper
Zend_View_Helper_Navigation => Zend/View/Helper/Navigation

to:

Zend_View_Helper_Navigation => Zend/View/Helper/Navigation
Zend_View_Helper => Zend/View/Helper
Default_View_Helper => application/views/helpers

Come to think of it, I suppose a quick fix that wouldn't involve any changes to the ZF source would be to explicitly add the ZF nav helper path to the view *before* adding any custom paths. A quick change to my application.ini should resolve this:

; View
resources.view.encoding = "UTF-8"
resources.view.basePath = APPLICATION_PATH "/views"
resources.view.helperPath.Zend_View_Helper_Navigation = "Zend/"
resources.view.helperPath.Default_View_Helper = APPLICATION_PATH "/views/helpers"

Thanks for the help! :)

--
Hector



On Thu, Jun 24, 2010 at 5:50 AM, Jurian Sluiman <subscribe@juriansluiman.nl> wrote:
I had exact the same case precise a year ago ;)
http://zend-framework-community.634137.n4.nabble.com/Zend-Navigation-visible-
in-sitemap-not-in-menu-td658632.html#a658633


I suggested to use a fallback when the default view helpers are not available,
but I never got an answer to that.

Regards, Jurian
--
Jurian Sluiman
CTO Soflomo V.O.F.
http://soflomo.com

On Thursday 24 Jun 2010 01:01:00 Hector Virgen wrote:
> Thanks, Jeroen. I think I'll go with that for now, but it would be nice if
> there was a better way.
>
> --
> Hector
>
> On Wed, Jun 23, 2010 at 3:46 PM, Jeroen Keppens
<jeroen.keppens@gmail.com>wrote:
> > I ended up doing exactly that (you hack), so I'm really curious aswell to
> > see other people's suggestions on this.
> >
> > Jeroen
> >
> > On 24 Jun 2010, at 00:40, Hector Virgen wrote:
> > > Hello,
> > >
> > > I need to extend Zend_View_Helper_Navigation_Menu to modify one of its
> >
> > methods. However, when calling $this->navigation()->menu() from within a
> > view, I always get the ZF version instead of my custom version. This
> > seems to happen because Zend_View_Helper_Navigation implicitly adds
> > Zend/View/Helper/Navigation to the end of the view helper's plugin loader
> > stack. Due to the stack being LIFO, it always returns the ZF helper
> > instead of mine.
> >
> > > Any suggestions on how to get around this? I'm considering giving my
> >
> > extended version a different name (such as "mymenu") but that seems like
> > a bit of a hack.
> >
> > > --
> > > Hector


Re: [fw-mvc] Extending navigation view helpers

Thanks Jurian. I like your suggestion, but maybe a simpler solution would be to place the ZF nav helper path closer to the beginning of the stack instead of the end. The final stack would go from looking like this:

Zend_View_Helper => Zend/View/Helper
My_View_Helper => My/View/Helper
Zend_View_Helper_Navigation => Zend/View/Helper/Navigation

to:

Zend_View_Helper_Navigation => Zend/View/Helper/Navigation
Zend_View_Helper => Zend/View/Helper
Default_View_Helper => application/views/helpers

Come to think of it, I suppose a quick fix that wouldn't involve any changes to the ZF source would be to explicitly add the ZF nav helper path to the view *before* adding any custom paths. A quick change to my application.ini should resolve this:

; View
resources.view.encoding = "UTF-8"
resources.view.basePath = APPLICATION_PATH "/views"
resources.view.helperPath.Zend_View_Helper_Navigation = "Zend/"
resources.view.helperPath.Default_View_Helper = APPLICATION_PATH "/views/helpers"

Thanks for the help! :)

--
Hector


On Thu, Jun 24, 2010 at 5:50 AM, Jurian Sluiman <subscribe@juriansluiman.nl> wrote:
I had exact the same case precise a year ago ;)
http://zend-framework-community.634137.n4.nabble.com/Zend-Navigation-visible-
in-sitemap-not-in-menu-td658632.html#a658633


I suggested to use a fallback when the default view helpers are not available,
but I never got an answer to that.

Regards, Jurian
--
Jurian Sluiman
CTO Soflomo V.O.F.
http://soflomo.com

On Thursday 24 Jun 2010 01:01:00 Hector Virgen wrote:
> Thanks, Jeroen. I think I'll go with that for now, but it would be nice if
> there was a better way.
>
> --
> Hector
>
> On Wed, Jun 23, 2010 at 3:46 PM, Jeroen Keppens
<jeroen.keppens@gmail.com>wrote:
> > I ended up doing exactly that (you hack), so I'm really curious aswell to
> > see other people's suggestions on this.
> >
> > Jeroen
> >
> > On 24 Jun 2010, at 00:40, Hector Virgen wrote:
> > > Hello,
> > >
> > > I need to extend Zend_View_Helper_Navigation_Menu to modify one of its
> >
> > methods. However, when calling $this->navigation()->menu() from within a
> > view, I always get the ZF version instead of my custom version. This
> > seems to happen because Zend_View_Helper_Navigation implicitly adds
> > Zend/View/Helper/Navigation to the end of the view helper's plugin loader
> > stack. Due to the stack being LIFO, it always returns the ZF helper
> > instead of mine.
> >
> > > Any suggestions on how to get around this? I'm considering giving my
> >
> > extended version a different name (such as "mymenu") but that seems like
> > a bit of a hack.
> >
> > > --
> > > Hector

Re: [fw-mvc] Extending navigation view helpers

I had exact the same case precise a year ago ;)
http://zend-framework-community.634137.n4.nabble.com/Zend-Navigation-visible-
in-sitemap-not-in-menu-td658632.html#a658633

I suggested to use a fallback when the default view helpers are not available,
but I never got an answer to that.

Regards, Jurian
--
Jurian Sluiman
CTO Soflomo V.O.F.
http://soflomo.com

On Thursday 24 Jun 2010 01:01:00 Hector Virgen wrote:
> Thanks, Jeroen. I think I'll go with that for now, but it would be nice if
> there was a better way.
>
> --
> Hector
>
> On Wed, Jun 23, 2010 at 3:46 PM, Jeroen Keppens
<jeroen.keppens@gmail.com>wrote:
> > I ended up doing exactly that (you hack), so I'm really curious aswell to
> > see other people's suggestions on this.
> >
> > Jeroen
> >
> > On 24 Jun 2010, at 00:40, Hector Virgen wrote:
> > > Hello,
> > >
> > > I need to extend Zend_View_Helper_Navigation_Menu to modify one of its
> >
> > methods. However, when calling $this->navigation()->menu() from within a
> > view, I always get the ZF version instead of my custom version. This
> > seems to happen because Zend_View_Helper_Navigation implicitly adds
> > Zend/View/Helper/Navigation to the end of the view helper's plugin loader
> > stack. Due to the stack being LIFO, it always returns the ZF helper
> > instead of mine.
> >
> > > Any suggestions on how to get around this? I'm considering giving my
> >
> > extended version a different name (such as "mymenu") but that seems like
> > a bit of a hack.
> >
> > > --
> > > Hector

2010年6月23日星期三

Re: [fw-mvc] Extending navigation view helpers

Thanks, Jeroen. I think I'll go with that for now, but it would be nice if there was a better way.

--
Hector


On Wed, Jun 23, 2010 at 3:46 PM, Jeroen Keppens <jeroen.keppens@gmail.com> wrote:
I ended up doing exactly that (you hack), so I'm really curious aswell to see other people's suggestions on this.

Jeroen

On 24 Jun 2010, at 00:40, Hector Virgen wrote:

> Hello,
>
> I need to extend Zend_View_Helper_Navigation_Menu to modify one of its methods. However, when calling $this->navigation()->menu() from within a view, I always get the ZF version instead of my custom version. This seems to happen because Zend_View_Helper_Navigation implicitly adds Zend/View/Helper/Navigation to the end of the view helper's plugin loader stack. Due to the stack being LIFO, it always returns the ZF helper instead of mine.
>
> Any suggestions on how to get around this? I'm considering giving my extended version a different name (such as "mymenu") but that seems like a bit of a hack.
>
> --
> Hector


Re: [fw-mvc] Extending navigation view helpers

I ended up doing exactly that (you hack), so I'm really curious aswell to see other people's suggestions on this.

Jeroen

On 24 Jun 2010, at 00:40, Hector Virgen wrote:

> Hello,
>
> I need to extend Zend_View_Helper_Navigation_Menu to modify one of its methods. However, when calling $this->navigation()->menu() from within a view, I always get the ZF version instead of my custom version. This seems to happen because Zend_View_Helper_Navigation implicitly adds Zend/View/Helper/Navigation to the end of the view helper's plugin loader stack. Due to the stack being LIFO, it always returns the ZF helper instead of mine.
>
> Any suggestions on how to get around this? I'm considering giving my extended version a different name (such as "mymenu") but that seems like a bit of a hack.
>
> --
> Hector

[fw-mvc] Extending navigation view helpers

Hello,

I need to extend Zend_View_Helper_Navigation_Menu to modify one of its methods. However, when calling $this->navigation()->menu() from within a view, I always get the ZF version instead of my custom version. This seems to happen because Zend_View_Helper_Navigation implicitly adds Zend/View/Helper/Navigation to the end of the view helper's plugin loader stack. Due to the stack being LIFO, it always returns the ZF helper instead of mine.

Any suggestions on how to get around this? I'm considering giving my extended version a different name (such as "mymenu") but that seems like a bit of a hack.

--
Hector

Re: [fw-db] how to use zend db with joins

correction: this is regular php but an alternative syntax, excuse my ignorance

On 23 June 2010 17:32, Timmo Henseler <timmo.henseler@gmail.com> wrote:
sorry, the manual isn't so overwhelming afterall, I found a (one of many perhaps) solution:

$db->setFetchMode(Zend_Db::FETCH_OBJ);
$result = $db->fetchAll($sql);

if(!empty($result)):
foreach($result as $row):
              // my code for showing results here (OO style, due to setFetchMode)
endforeach;
else:
echo 'nothing found';
endif;

A regular php loop as far as I can see but syntax a little different. Hope this helps others.

Timmo

On 23 June 2010 12:58, Timmo Henseler <timmo.henseler@gmail.com> wrote:
Jeroen, great, thanks, this seems to work!

I say seems because I have moved from:

if ($result = $db->select($sql)) {   // no errors anymore

to:

while ($row = $result->fetch_object()) {

where I need to translate fetch_object to Zend methods.

You know I am still in the phase where I am (slightly) comfortable with php (as to below I actually meant raw php) but Zend is still scary, so I appreciate your help very much.

Timmo

On 23 June 2010 12:17, Jeroen Keppens <jeroen.keppens@gmail.com> wrote:
If I need to get the DB for a custom query or so, I usually do it like this (be sure to set it as default adapter in the config) :

$db = Zend_Db_Table::getDefaultAdapter();

That way you have an instantiated db object. If you haven't used it yet, the connection is not open yet. Once you have used it once, all DB queries will use the same connection.

Now, if you want to show your list on page 1 and then update on page 2 (so in different requests), your DB connection will be remade. It's standard behaviour unless you use persistent connections... but I'm not a fan of those.

Regarding best practices: as long as you put the queries in your data layer, it doesn't matter how you use it in my opinion. Just don't put plain SQL in your controller or domain models.

Wkr
Jeroen

On 23 Jun 2010, at 11:25, Timmo Henseler wrote:

Jeroen, thanks, yes this helps a lot. when i use raw queries for update can I then just assume that the database connection is still there (I read something about lazy connections) or do I have to approach the database with regular mysqli? Is it good practice to mix zend db code with raw php/mysqli for the same model/database?

Timmo

On 23 June 2010 11:12, Jeroen Keppens <jeroen.keppens@gmail.com> wrote:
I would say that Zend_Db_Select is the way to go to do your joins in selects:

Example from the docs:

  1. // Build this query:
  2. //   SELECT p."product_id", p."product_name"
  3. //   FROM "products" AS p JOIN "line_items" AS l
  4. //     ON p.product_id = l.product_id
  5.  
  6. $select = $db->select()
  7.              ->from(array('p' => 'products'),
  8.                     array('product_id', 'product_name'))
  9.              ->join(array('l' => 'line_items'),
  10.                     'p.product_id = l.product_id',
  11.                     array() ); // empty list of columns
If you want fields from the second table add the column names in the example where it says "empty list of columns".

If you want to do updates on multiple tables using joins, you'll have to use raw queries since ZF db->update does not support that as far as I know.

Hope this helps!

Wkr
Jeroen

On 23 Jun 2010, at 10:58, zensys wrote:


Just a general question on how to best utilise zend db. I have a few tables
which I want to display with join statements and update afterwards. Not a
very complicated schema but quite some fields which I want to select
individually. To my limited understanding of DB I have the following
options:

- instantiate an adapter and just go from there using db->query() etc.
- use db select
- instantiate a db table for each of my tables and use joins (or db select?)
from there.

From what I've read in the manual it seems like only use an adapter gives
the least overhead. Db select is only for complicated queries and anyway you
cannot update with joins. Instantiate db tables for each table also sounds
like some overhead and I do not see the advantages.

Anyone any thoughts on this?

And another thing: do I need to instantiate an adapter but have the
resource.db.params in my application.ini . In that case, is the adapter
already instantiated and if so how do I reference it. If not, using the
db_factory? But it asks for parameters.
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/how-to-use-zend-db-with-joins-tp2265294p2265294.html
Sent from the Zend DB mailing list archive at Nabble.com.







Re: [fw-db] how to use zend db with joins

Jeroen, great, thanks, this seems to work!

I say seems because I have moved from:

if ($result = $db->select($sql)) {   // no errors anymore

to:

while ($row = $result->fetch_object()) {

where I need to translate fetch_object to Zend methods.

You know I am still in the phase where I am (slightly) comfortable with php (as to below I actually meant raw php) but Zend is still scary, so I appreciate your help very much.

Timmo

On 23 June 2010 12:17, Jeroen Keppens <jeroen.keppens@gmail.com> wrote:
If I need to get the DB for a custom query or so, I usually do it like this (be sure to set it as default adapter in the config) :

$db = Zend_Db_Table::getDefaultAdapter();

That way you have an instantiated db object. If you haven't used it yet, the connection is not open yet. Once you have used it once, all DB queries will use the same connection.

Now, if you want to show your list on page 1 and then update on page 2 (so in different requests), your DB connection will be remade. It's standard behaviour unless you use persistent connections... but I'm not a fan of those.

Regarding best practices: as long as you put the queries in your data layer, it doesn't matter how you use it in my opinion. Just don't put plain SQL in your controller or domain models.

Wkr
Jeroen

On 23 Jun 2010, at 11:25, Timmo Henseler wrote:

Jeroen, thanks, yes this helps a lot. when i use raw queries for update can I then just assume that the database connection is still there (I read something about lazy connections) or do I have to approach the database with regular mysqli? Is it good practice to mix zend db code with raw php/mysqli for the same model/database?

Timmo

On 23 June 2010 11:12, Jeroen Keppens <jeroen.keppens@gmail.com> wrote:
I would say that Zend_Db_Select is the way to go to do your joins in selects:

Example from the docs:

  1. // Build this query:
  2. //   SELECT p."product_id", p."product_name"
  3. //   FROM "products" AS p JOIN "line_items" AS l
  4. //     ON p.product_id = l.product_id
  5.  
  6. $select = $db->select()
  7.              ->from(array('p' => 'products'),
  8.                     array('product_id', 'product_name'))
  9.              ->join(array('l' => 'line_items'),
  10.                     'p.product_id = l.product_id',
  11.                     array() ); // empty list of columns
If you want fields from the second table add the column names in the example where it says "empty list of columns".

If you want to do updates on multiple tables using joins, you'll have to use raw queries since ZF db->update does not support that as far as I know.

Hope this helps!

Wkr
Jeroen

On 23 Jun 2010, at 10:58, zensys wrote:


Just a general question on how to best utilise zend db. I have a few tables
which I want to display with join statements and update afterwards. Not a
very complicated schema but quite some fields which I want to select
individually. To my limited understanding of DB I have the following
options:

- instantiate an adapter and just go from there using db->query() etc.
- use db select
- instantiate a db table for each of my tables and use joins (or db select?)
from there.

From what I've read in the manual it seems like only use an adapter gives
the least overhead. Db select is only for complicated queries and anyway you
cannot update with joins. Instantiate db tables for each table also sounds
like some overhead and I do not see the advantages.

Anyone any thoughts on this?

And another thing: do I need to instantiate an adapter but have the
resource.db.params in my application.ini . In that case, is the adapter
already instantiated and if so how do I reference it. If not, using the
db_factory? But it asks for parameters.
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/how-to-use-zend-db-with-joins-tp2265294p2265294.html
Sent from the Zend DB mailing list archive at Nabble.com.





Re: [fw-db] how to use zend db with joins

I think he meant raw queries trought the Zend_Db adapter vs Zend_Db_Select queries (both using ZF DB functions). Not raw php functions.

Wkr
Jeroen

On 23 Jun 2010, at 12:17, Vincent de Lau wrote:

>> -----Oorspronkelijk bericht-----
>> Van: Timmo Henseler [mailto:timmo.henseler@gmail.com]
>>
>> Jeroen, thanks, yes this helps a lot. when i use raw queries for update
>> can I then just assume that the database connection is still there (I
>> read something about lazy connections) or do I have to approach the
>> database with regular mysqli? Is it good practice to mix zend db code
>> with raw php/mysqli for the same model/database?
>
> Lazy connecting means that Zend_Db_Adapter will not connect until you do an
> actual query. It stores the connection details until they are needed. This
> has the advantage that you can setup your adapter before you even know if
> you need it. Lazy connection will not drop connections or something like
> that.
>
> I think mixing ZF and 'raw' PHP functions is something to avoid, although it
> is perfectly possible. Zend_Db_Adapter even provides a getConnection()
> method that will get the native connection resource for you. (The underlying
> MySQLi object probably.) The connection is initiated if it wasn't already.
>
> Vincent de Lau
> vincent@delau.nl
>

RE: [fw-db] how to use zend db with joins

> -----Oorspronkelijk bericht-----
> Van: Timmo Henseler [mailto:timmo.henseler@gmail.com]
>
> Jeroen, thanks, yes this helps a lot. when i use raw queries for update
> can I then just assume that the database connection is still there (I
> read something about lazy connections) or do I have to approach the
> database with regular mysqli? Is it good practice to mix zend db code
> with raw php/mysqli for the same model/database?

Lazy connecting means that Zend_Db_Adapter will not connect until you do an
actual query. It stores the connection details until they are needed. This
has the advantage that you can setup your adapter before you even know if
you need it. Lazy connection will not drop connections or something like
that.

I think mixing ZF and 'raw' PHP functions is something to avoid, although it
is perfectly possible. Zend_Db_Adapter even provides a getConnection()
method that will get the native connection resource for you. (The underlying
MySQLi object probably.) The connection is initiated if it wasn't already.

Vincent de Lau
vincent@delau.nl

Re: [fw-db] how to use zend db with joins

If I need to get the DB for a custom query or so, I usually do it like this (be sure to set it as default adapter in the config) :

$db = Zend_Db_Table::getDefaultAdapter();

That way you have an instantiated db object. If you haven't used it yet, the connection is not open yet. Once you have used it once, all DB queries will use the same connection.

Now, if you want to show your list on page 1 and then update on page 2 (so in different requests), your DB connection will be remade. It's standard behaviour unless you use persistent connections... but I'm not a fan of those.

Regarding best practices: as long as you put the queries in your data layer, it doesn't matter how you use it in my opinion. Just don't put plain SQL in your controller or domain models.

Wkr
Jeroen

On 23 Jun 2010, at 11:25, Timmo Henseler wrote:

Jeroen, thanks, yes this helps a lot. when i use raw queries for update can I then just assume that the database connection is still there (I read something about lazy connections) or do I have to approach the database with regular mysqli? Is it good practice to mix zend db code with raw php/mysqli for the same model/database?

Timmo

On 23 June 2010 11:12, Jeroen Keppens <jeroen.keppens@gmail.com> wrote:
I would say that Zend_Db_Select is the way to go to do your joins in selects:

Example from the docs:

  1. // Build this query:
  2. //   SELECT p."product_id", p."product_name"
  3. //   FROM "products" AS p JOIN "line_items" AS l
  4. //     ON p.product_id = l.product_id
  5.  
  6. $select = $db->select()
  7.              ->from(array('p' => 'products'),
  8.                     array('product_id', 'product_name'))
  9.              ->join(array('l' => 'line_items'),
  10.                     'p.product_id = l.product_id',
  11.                     array() ); // empty list of columns
If you want fields from the second table add the column names in the example where it says "empty list of columns".

If you want to do updates on multiple tables using joins, you'll have to use raw queries since ZF db->update does not support that as far as I know.

Hope this helps!

Wkr
Jeroen

On 23 Jun 2010, at 10:58, zensys wrote:


Just a general question on how to best utilise zend db. I have a few tables
which I want to display with join statements and update afterwards. Not a
very complicated schema but quite some fields which I want to select
individually. To my limited understanding of DB I have the following
options:

- instantiate an adapter and just go from there using db->query() etc.
- use db select
- instantiate a db table for each of my tables and use joins (or db select?)
from there.

From what I've read in the manual it seems like only use an adapter gives
the least overhead. Db select is only for complicated queries and anyway you
cannot update with joins. Instantiate db tables for each table also sounds
like some overhead and I do not see the advantages.

Anyone any thoughts on this?

And another thing: do I need to instantiate an adapter but have the
resource.db.params in my application.ini . In that case, is the adapter
already instantiated and if so how do I reference it. If not, using the
db_factory? But it asks for parameters.
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/how-to-use-zend-db-with-joins-tp2265294p2265294.html
Sent from the Zend DB mailing list archive at Nabble.com.




Re: [fw-db] how to use zend db with joins

<?php
class Model_Managers_AssignUserToMenu extends Zend_Db_Table_Abstract {

protected $_name = 'GNL_USER_MENU';
......

}



$table = new Model_Managers_AssignUserToMenu();

$select = $table->select(Zend_Db_Table::SELECT_WITH_FROM_PART);
$select = $table->select(Zend_Db_Select::DISTINCT);
$select->setIntegrityCheck(FALSE)
// ->distinct(true)
->join('GNL_ARC_MENU', 'GNL_ARC_MENU.MENU_ID = GNL_USER_MENU.MENU_ID')
->order('GNL_USER_MENU.MENU_ID');

$result = $table->fetchAll($select);
I would like to raise a question here since ZEND_DB and JOIN are in discussion;

i tried to use DISTINCT with ZEND_DB_SELECT's JOIN...but seems like it doesnt work...with this email i'm attaching the code i was using it with..

Thanx in advance

On Wed, Jun 23, 2010 at 1:12 PM, Jeroen Keppens <jeroen.keppens@gmail.com> wrote:
I would say that Zend_Db_Select is the way to go to do your joins in selects:

Example from the docs:

  1. // Build this query:
  2. //   SELECT p."product_id", p."product_name"
  3. //   FROM "products" AS p JOIN "line_items" AS l
  4. //     ON p.product_id = l.product_id
  5.  
  6. $select = $db->select()
  7.              ->from(array('p' => 'products'),
  8.                     array('product_id', 'product_name'))
  9.              ->join(array('l' => 'line_items'),
  10.                     'p.product_id = l.product_id',
  11.                     array() ); // empty list of columns
If you want fields from the second table add the column names in the example where it says "empty list of columns".

If you want to do updates on multiple tables using joins, you'll have to use raw queries since ZF db->update does not support that as far as I know.

Hope this helps!

Wkr
Jeroen

On 23 Jun 2010, at 10:58, zensys wrote:


Just a general question on how to best utilise zend db. I have a few tables
which I want to display with join statements and update afterwards. Not a
very complicated schema but quite some fields which I want to select
individually. To my limited understanding of DB I have the following
options:

- instantiate an adapter and just go from there using db->query() etc.
- use db select
- instantiate a db table for each of my tables and use joins (or db select?)
from there.

From what I've read in the manual it seems like only use an adapter gives
the least overhead. Db select is only for complicated queries and anyway you
cannot update with joins. Instantiate db tables for each table also sounds
like some overhead and I do not see the advantages.

Anyone any thoughts on this?

And another thing: do I need to instantiate an adapter but have the
resource.db.params in my application.ini . In that case, is the adapter
already instantiated and if so how do I reference it. If not, using the
db_factory? But it asks for parameters.
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/how-to-use-zend-db-with-joins-tp2265294p2265294.html
Sent from the Zend DB mailing list archive at Nabble.com.





--
Regards,
YD

Re: [fw-db] how to use zend db with joins

Jeroen, thanks, yes this helps a lot. when i use raw queries for update can I then just assume that the database connection is still there (I read something about lazy connections) or do I have to approach the database with regular mysqli? Is it good practice to mix zend db code with raw php/mysqli for the same model/database?

Timmo

On 23 June 2010 11:12, Jeroen Keppens <jeroen.keppens@gmail.com> wrote:
I would say that Zend_Db_Select is the way to go to do your joins in selects:

Example from the docs:

  1. // Build this query:
  2. //   SELECT p."product_id", p."product_name"
  3. //   FROM "products" AS p JOIN "line_items" AS l
  4. //     ON p.product_id = l.product_id
  5.  
  6. $select = $db->select()
  7.              ->from(array('p' => 'products'),
  8.                     array('product_id', 'product_name'))
  9.              ->join(array('l' => 'line_items'),
  10.                     'p.product_id = l.product_id',
  11.                     array() ); // empty list of columns
If you want fields from the second table add the column names in the example where it says "empty list of columns".

If you want to do updates on multiple tables using joins, you'll have to use raw queries since ZF db->update does not support that as far as I know.

Hope this helps!

Wkr
Jeroen

On 23 Jun 2010, at 10:58, zensys wrote:


Just a general question on how to best utilise zend db. I have a few tables
which I want to display with join statements and update afterwards. Not a
very complicated schema but quite some fields which I want to select
individually. To my limited understanding of DB I have the following
options:

- instantiate an adapter and just go from there using db->query() etc.
- use db select
- instantiate a db table for each of my tables and use joins (or db select?)
from there.

From what I've read in the manual it seems like only use an adapter gives
the least overhead. Db select is only for complicated queries and anyway you
cannot update with joins. Instantiate db tables for each table also sounds
like some overhead and I do not see the advantages.

Anyone any thoughts on this?

And another thing: do I need to instantiate an adapter but have the
resource.db.params in my application.ini . In that case, is the adapter
already instantiated and if so how do I reference it. If not, using the
db_factory? But it asks for parameters.
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/how-to-use-zend-db-with-joins-tp2265294p2265294.html
Sent from the Zend DB mailing list archive at Nabble.com.



Re: [fw-db] how to use zend db with joins

I would say that Zend_Db_Select is the way to go to do your joins in selects:

Example from the docs:

  1. // Build this query:
  2. //   SELECT p."product_id", p."product_name"
  3. //   FROM "products" AS p JOIN "line_items" AS l
  4. //     ON p.product_id = l.product_id
  5.  
  6. $select = $db->select()
  7.              ->from(array('p' => 'products'),
  8.                     array('product_id', 'product_name'))
  9.              ->join(array('l' => 'line_items'),
  10.                     'p.product_id = l.product_id',
  11.                     array() ); // empty list of columns
If you want fields from the second table add the column names in the example where it says "empty list of columns".

If you want to do updates on multiple tables using joins, you'll have to use raw queries since ZF db->update does not support that as far as I know.

Hope this helps!

Wkr
Jeroen

On 23 Jun 2010, at 10:58, zensys wrote:


Just a general question on how to best utilise zend db. I have a few tables
which I want to display with join statements and update afterwards. Not a
very complicated schema but quite some fields which I want to select
individually. To my limited understanding of DB I have the following
options:

- instantiate an adapter and just go from there using db->query() etc.
- use db select
- instantiate a db table for each of my tables and use joins (or db select?)
from there.

From what I've read in the manual it seems like only use an adapter gives
the least overhead. Db select is only for complicated queries and anyway you
cannot update with joins. Instantiate db tables for each table also sounds
like some overhead and I do not see the advantages.

Anyone any thoughts on this?

And another thing: do I need to instantiate an adapter but have the
resource.db.params in my application.ini . In that case, is the adapter
already instantiated and if so how do I reference it. If not, using the
db_factory? But it asks for parameters.
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/how-to-use-zend-db-with-joins-tp2265294p2265294.html
Sent from the Zend DB mailing list archive at Nabble.com.


[fw-db] how to use zend db with joins

Just a general question on how to best utilise zend db. I have a few tables
which I want to display with join statements and update afterwards. Not a
very complicated schema but quite some fields which I want to select
individually. To my limited understanding of DB I have the following
options:

- instantiate an adapter and just go from there using db->query() etc.
- use db select
- instantiate a db table for each of my tables and use joins (or db select?)
from there.

>From what I've read in the manual it seems like only use an adapter gives
the least overhead. Db select is only for complicated queries and anyway you
cannot update with joins. Instantiate db tables for each table also sounds
like some overhead and I do not see the advantages.

Anyone any thoughts on this?

And another thing: do I need to instantiate an adapter but have the
resource.db.params in my application.ini . In that case, is the adapter
already instantiated and if so how do I reference it. If not, using the
db_factory? But it asks for parameters.
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/how-to-use-zend-db-with-joins-tp2265294p2265294.html
Sent from the Zend DB mailing list archive at Nabble.com.

2010年6月21日星期一

Re: [fw-auth] Zend_ACl

Hi Trinath,

I wrote a blog post on ACL / models a couple of weeks ago. It's not 100% what you are looking for I think, but it might get you on route to a solution. It shows how you can use ACL in your models, perform checks and in the case of the article make sure the visitor has access on a content-specific item (i.e. not just on "Article" but on a specific article).

http://www.amazium.com/blog/content-driven-access-control-with-zend-acl

Instead of having "device management" as a resource, you could have "device" as a resource. Your device model would then implement the Resource interface. Your actions add, edit, delete, view etc... would be privileges. You can then check in your service layer (or controller) if a User (implementing role) has edit (privilege) access on Device (implementing a resource) and then call the edit function on your module (or something similar).

Hope this is a good start for you.

wkr,
Jeroen

On 21 Jun 2010, at 13:51, Trinath Somanchi wrote:

> Hi All,
>
> I'm new to Zend_Acl and interested in knowing how it will be suiting for my ACL structure.
>
> The following are the Roles:
>
> [1] Super User
> [2] Administrator
> [3] Manager
> [4] Guest
>
> The following are the Resources.
>
> [1] Device Management
> [2] Application Management
> [3] Object Management
> [4] User Management
> [5] Server Administration
>
> And the following are the Rules.
>
> [1] Add/Edit/Delete User
> [2] Add/Edit/Delete Device
> [3] Allow access to Device for other users.
> [4] Add/Edit/Delete Application
> [5] Allow access to Application for other users.
> [6] Add/Edit/Delete Objects
> [7] Allow access to Objects for other users.
> [8] Do Database Backup
> [9] Archive and Restore Database
>
> All the above rules are assigned to ROLES. And Users are assigned to Roles.
>
> As it is clear, Any user having a Role can perform the tasks in the server/system as applicable with respect to the Rules present in the roles.
>
> Now, A user can ADD/EDIT/DELETE Devices, Application and Objects. Also I have another ACL for Devices, Applications and objects.
>
> User Bob (holds manager role) who owns a Device can create Applications for the device and objects for the application.
>
> Now Bob wants user John to have privilege to access for all objects under Application "ABC" under Device "DD1".
>
> Also Bob wants to provide access for using objects "OBJ-1" and "OBJ-3" which he owned under Application "DEF" under Device "DD1".
>
> And also Bob wants to add another user "Jane" and wants to grant privilege for accessing Objects "OBJ-5" under Application "GHI" and all objects under Application "DHG" which under Device "DD1".
>
> The achieve the above use case, Bob must have Rules assigned to his role mentioned above from [1] to [7].
>
> Pleas help me on how Zend_ACL can be user for achieving this ACL.
>
> Thanks in advance.
>
>
> --
> Regards,
> ----------------------------------------------
> Trinath Somanchi,

[fw-auth] Zend_ACl

Hi All,

I'm new to Zend_Acl and interested in knowing how it will be suiting for my ACL structure.

The following are the Roles:

[1] Super User
[2] Administrator
[3] Manager
[4] Guest

The following are the Resources.

[1] Device Management
[2] Application Management
[3] Object Management
[4] User Management
[5] Server Administration

And the following are the Rules.

[1] Add/Edit/Delete User
[2] Add/Edit/Delete Device
[3] Allow access to Device for other users.
[4] Add/Edit/Delete Application
[5] Allow access to Application for other users.
[6] Add/Edit/Delete Objects
[7] Allow access to Objects for other users.
[8] Do Database Backup
[9] Archive and Restore Database

All the above rules are assigned to ROLES. And Users are assigned to Roles.

As it is clear, Any user having a Role can perform the tasks in the server/system as applicable with respect to the Rules present in the roles.

Now, A user can ADD/EDIT/DELETE Devices, Application and Objects. Also I have another ACL for Devices, Applications and objects.

User Bob (holds manager role) who owns a Device can create Applications for the device and objects for the application.

Now Bob wants user John to have privilege to access for all objects under  Application "ABC" under Device "DD1". 

Also Bob wants to provide access for using objects "OBJ-1" and "OBJ-3" which he owned under Application "DEF" under Device "DD1". 

And also Bob wants to add another user "Jane" and wants to grant privilege for accessing Objects "OBJ-5" under Application "GHI" and all objects under Application "DHG" which under Device "DD1".

The achieve the above use case, Bob must have Rules assigned to his role mentioned above from [1] to [7].

Pleas help me on how Zend_ACL can be user for achieving this ACL.

Thanks in advance.


--
Regards,
----------------------------------------------
Trinath Somanchi,

2010年6月19日星期六

Re: [fw-webservices] Zend_Rest - Zend_Http_Client changing arguments

I'm sure it's a bug, but it's furthermore a problem with the design
and purpose of Zend_Rest_Client itself. You should really just use
Zend_Http_Client.

-L

On Sat, Jun 19, 2010 at 4:19 PM, Matthias Frey <info@frey-it.com> wrote:
> Hello,
>
> I am trying to use Zend_Rest with the Flickr-API, wanting to use one of the
> "signed" method calls. These require the arguments to be in a certain order.
>
> This failed using Zend_Rest, I then dumped the Zend_Http_Client object, and
> found the property paramsGet , which I suppose is the array that holds the
> query parameters for the get-request.
>
>   [paramsGet:protected] => Array
>       (
>           [method] => flickr.auth.getToken
>           [arg1] => e30c9490736794845e10a58753492239
>           [api_key] => e30c9490736794845e10a58753492239
>           [frob] => 72157624310932518-b0e116d497a3b043-49815721
>           [api_sig] => b7b0042b0276668d6103829aca9abf97
>           [rest] => 1
>       )
>
>
> It seems that
> - the order of the arguments is not contained,
> - an argument "arg1" is added for some reason
> - another argument "rest" is added
>
> Is there a reason for that ? Any thoughts whether this is a bug , or how to
> "turn it off" .
>
> Btw, I am using Zend_Rest like
> ...
> $client->method('flickr.auth.getToken');
> ... etc
>
> Thanks for your help.
> Regards, Matthias
>

[fw-webservices] Zend_Rest - Zend_Http_Client changing arguments

Hello,

I am trying to use Zend_Rest with the Flickr-API, wanting to use one of
the "signed" method calls. These require the arguments to be in a
certain order.

This failed using Zend_Rest, I then dumped the Zend_Http_Client object,
and found the property paramsGet , which I suppose is the array that
holds the query parameters for the get-request.

[paramsGet:protected] => Array
(
[method] => flickr.auth.getToken
[arg1] => e30c9490736794845e10a58753492239
[api_key] => e30c9490736794845e10a58753492239
[frob] => 72157624310932518-b0e116d497a3b043-49815721
[api_sig] => b7b0042b0276668d6103829aca9abf97
[rest] => 1
)


It seems that
- the order of the arguments is not contained,
- an argument "arg1" is added for some reason
- another argument "rest" is added

Is there a reason for that ? Any thoughts whether this is a bug , or how
to "turn it off" .

Btw, I am using Zend_Rest like
...
$client->method('flickr.auth.getToken');
... etc

Thanks for your help.
Regards, Matthias