2011年2月28日星期一

Re: [fw-mvc] Zend framework ACL - newbie help needed

-- Rishi Daryanani <rishijd@yahoo.com> wrote
(on Monday, 28 February 2011, 06:06 AM -0800):
> I'm very new to ACL and it's not something we've tried below. Any guidance would
> be appreciated; I'm going to start with code experimentation but would like to
> know if I'm on the right track.
>
>
> We are using a custom developed CMS which is using ZF", and we have our front
> end website as well. The CMS uses a controller called "AdminController", and the
> front end only uses a controller called "IndexController". I want to introduce
> access control to this CMS. Therefore some user groups will be restricted to
> some areas of the CMS.
>
> Current potential solution :
>
> I'm thinking of achieving this functionality as described below.
>
> 1. Have a database table to store the type of the user.
> 2. Have a separate table to store the pages the user is allowed or not allowed.
> 3. Check in each page whether the user have the access or not and display the
> page accordingly.
>
> Which is the best way to implement this using Zend framework? "Zend_Auth" or
> "Zend_Acl" ?

Zend_Auth is used for authentication of a user; i.e., evaluating the
provided credentials to determine identity.

Zend_Acl is used for authorization; i.e., to determine whether a given
user has the rights to access a given resource.

What you describe above is the realm of Zend_Acl.

> I have looked in to the "Zend_Acl" and it sounds good, however
> could someone guide me - what is the procedure for implementing this? Here are
> the links I found:
> http://framework.zend.com/manual/en/zend.acl.introduction.html
> http://framework.zend.com/wiki/pages/viewpage.action?pageId=39025

The basic workflow is:

* Create a Zend_Acl object
* Add roles to the Zend_Acl object
* Add resources to the Zend_Acl object
* Create the permissions

Now, that said, there are a variety of ways to do this. You can do it
up-front -- i.e., define all roles, resources, and permissions in a
given object or in your bootstrap. If you have only a handful of ACLs to
create, this is a straight-forward approach.

Another approach is to add them as you need them.

As an example, when you grab the user identity during login or later
from the Zend_Auth session container, you might include the role in the
identity information. You can then add this to the ACL as you grab it:

$acl->addRole($identity->role);

You could also define an array of roles, and then one master role for
the user (which would indicate the user inherits all of those roles):

foreach ($identity->roles as $role) {
$acl->addRole($role);
}
$acl->addRole($identity->username, $identity->roles);

Later, when you grab your page, you might also include ACL information
in the page metadata. This allows you to setup the resource and
permissions ad-hoc. As an example, let's assume that a "page" object
might have the following in its structure:

public $identifier;
public $roles = array(
array('role' => array('read', 'write'))
);

$acl->addResource($page->identifier);
foreach ($page->roles as $role => $rights) {
if (!$acl->hasRole($role)) {
$acl->addRole($role);
}
$acl->allow($role, $page->identifier, $rights);
}

Then, you can test right there and then:

if (!$acl->isAllowed($identity->role, $page->identifier, $currentPrivilege)) {
throw new AclException;
}

This allows you some flexibility -- you don't have to define all ACLs up
front, and can grow the graph as your content grows. That said, it can
get tricky if you want to introduce role inheritance, so you have to
setup a strict convention of how the roles are stored.

Hope that helps get you started!

> The gist of my understanding is:
> - In the AdminController (or is it bootstrap.php) I have to define a set of
> Roles and Resources that are accessed/denied for those roles. This follows the
> above tutorial example. In my case, I need to add a new user role called "staff
> user" who will just have access to one function in the CMS, a basic "customer
> lookup" reporting function.
>
> - However I also need to check (in the "customer lookup" function) if the
> logged-in user has access rights to view this page. In all other pages, I need
> to DENY access rights actually, if the logged in user is a "staff user". Is
> there a tutorial like this which explains it for newbies? Or could someone guide
> me on what kind of code goes where?
>
> I'm not sure how I can tell ZF the name of the resource of each section/function
> of the CMS. For example, if I have a section called "Reports", and functions
> called
> - "Customer Lookup"
> - "Orders report"
> - "Members report"
>
> then what code would I put in for each of the above controller functions to
> assign a resource name and possibly a module/sub-resource name to each function?
>
> Many thanks,
> Rishi
>
>
>

--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

[fw-mvc] Zend framework ACL - newbie help needed

Hi,

I'm very new to ACL and it's not something we've tried below. Any guidance would
be appreciated; I'm going to start with code experimentation but would like to
know if I'm on the right track.


We are using a custom developed CMS which is using ZF", and we have our front
end website as well. The CMS uses a controller called "AdminController", and the
front end only uses a controller called "IndexController". I want to introduce
access control to this CMS. Therefore some user groups will be restricted to
some areas of the CMS.

Current potential solution :

I'm thinking of achieving this functionality as described below.

1. Have a database table to store the type of the user.
2. Have a separate table to store the pages the user is allowed or not allowed.
3. Check in each page whether the user have the access or not and display the
page accordingly.

Which is the best way to implement this using Zend framework? "Zend_Auth" or
"Zend_Acl" ? I have looked in to the "Zend_Acl" and it sounds good, however
could someone guide me - what is the procedure for implementing this? Here are
the links I found:
http://framework.zend.com/manual/en/zend.acl.introduction.html
http://framework.zend.com/wiki/pages/viewpage.action?pageId=39025

The gist of my understanding is:
- In the AdminController (or is it bootstrap.php) I have to define a set of
Roles and Resources that are accessed/denied for those roles. This follows the
above tutorial example. In my case, I need to add a new user role called "staff
user" who will just have access to one function in the CMS, a basic "customer
lookup" reporting function.

- However I also need to check (in the "customer lookup" function) if the
logged-in user has access rights to view this page. In all other pages, I need
to DENY access rights actually, if the logged in user is a "staff user". Is
there a tutorial like this which explains it for newbies? Or could someone guide
me on what kind of code goes where?

I'm not sure how I can tell ZF the name of the resource of each section/function
of the CMS. For example, if I have a section called "Reports", and functions
called
- "Customer Lookup"
- "Orders report"
- "Members report"

then what code would I put in for each of the above controller functions to
assign a resource name and possibly a module/sub-resource name to each function?

Many thanks,
Rishi

2011年2月25日星期五

Re: [fw-db] Zend_Db_Table Issue

On Thu, Feb 24, 2011 at 6:40 PM, Bill Karwin <bill@karwin.com> wrote:

>
> On Feb 24, 2011, at 1:55 PM, David Mintz wrote:
>
> Thanks for the helpful observations. The trouble with NULL is that it's
>> too vague. I have cases where I need something that means "not applicable,"
>> "unknown," or most often, "we don't care" because the proceeding took place
>> before the generic duty magistrate whose actual identity really isn't
>> important, and users don't want to be forced to identify her/him by name.
>>
>
> Fair enough. For what it's worth, it has been a subject of debate over
> many years among relational theorists whether NULL should be a single value
> or should there be multiple "types" of NULL for different purposes. E.g.
> "applicable but unknown at this time" is different from "inapplicable".
> There have been proposals for up to four different types of NULL-like
> value.
>
> On the other extreme, people like C. J. Date argue strongly that any kind
> of NULL is inappropriate in the relational model.
>
> In your case, I'd still recommend using NULL for the foreign key, simply
> because it solves your issue with -1. The worst solution in my view is to
> use a non-null value to do what NULL is meant to do. Once you start saying,
> "we can't use DRI constraints because..." then IMHO it doesn't matter how
> you finish that sentence, because you've already broken your logical
> database design.
>
> If you still need to distinguish between "n/a", "unknown" or "we don't
> care" then add another column called `why_no_judge` or something.
>
>

Say no more! I'm convinced. I am sort of an enthusiast programmer, a guy
with a non-IT job title who has picked up skills to solve problems in the
workplace (there being no one else in the organization to do it). In my
non-expert opinion this is a situation where you have to do something a
little ugly, that doesn't feel completely right, no matter what. And I think
your solution is less ugly and will work better than what I was going to do.
Thanks.

--
David Mintz
http://davidmintz.org/
It ain't over:
http://www.healthcare-now.org/

2011年2月24日星期四

Re: [fw-gdata] Bad request

Catch the exception and look for the body of it (var_dump if necessary) It
should provide more info about the cause of the exception for the body of
the HttpResponse object.

Cheers,
-Ryan


On Thu, Feb 24, 2011 at 2:53 AM, knasboll <tony@perfectfools.com> wrote:

>
> Please advi
> ce...
> This code below returns
>
> [code:protected] => 400
> [message:protected] => Bad Request
>
> Cannot figure out how to do it, xxx is correct in my code :)
>
> $client = Zend_Gdata_ClientLogin::getHttpClient($email, $password,
> Zend_Gdata_Gapps::AUTH_SERVICE_NAME);
> $service = new Zend_Gdata_Gapps($client, $domain);
>
> $get =
> "https://apps-apis.google.com/a/feeds/emailsettings/2.0/xxx.com/xxx/";
>
> $client->setUri($get);
> $client->request('GET');
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/Bad-request-tp3322408p3322408.html
> Sent from the Zend gdata mailing list archive at Nabble.com.
>

Re: [fw-mvc] Sessions and passing them between websites

Hey Thomas,

> idea is to be able to embed a form on another website, and then process that form through Action controllers on a site built using the Zend Framework

Why are sessions required? Can you just have the form on site A POST to
the form on site B?

If you did go this route, any non-valid form handling would happen on
site B, but outside of that you can do this without any sessions.

If it is imperative that site A always display the form including the
in-valid form processing results (error messages, required fields, etc),
then you'll need to find a way to make Site A and site B share
information. If these sites are not sharing the same top level domain
name, this gets harder b/c the session identifier used by Zend_Session
will not be the same (that would require some kind of SSO solution.)

Ultimately, it depends on how complex your solution to be.

-ralph

Re: [fw-db] Zend_Db_Table Issue

On Feb 24, 2011, at 1:55 PM, David Mintz wrote:

> Thanks for the helpful observations. The trouble with NULL is that
> it's too vague. I have cases where I need something that means "not
> applicable," "unknown," or most often, "we don't care" because the
> proceeding took place before the generic duty magistrate whose
> actual identity really isn't important, and users don't want to be
> forced to identify her/him by name.

Fair enough. For what it's worth, it has been a subject of debate
over many years among relational theorists whether NULL should be a
single value or should there be multiple "types" of NULL for different
purposes. E.g. "applicable but unknown at this time" is different
from "inapplicable". There have been proposals for up to four
different types of NULL-like value.

On the other extreme, people like C. J. Date argue strongly that any
kind of NULL is inappropriate in the relational model.

In your case, I'd still recommend using NULL for the foreign key,
simply because it solves your issue with -1. The worst solution in my
view is to use a non-null value to do what NULL is meant to do. Once
you start saying, "we can't use DRI constraints because..." then IMHO
it doesn't matter how you finish that sentence, because you've already
broken your logical database design.

If you still need to distinguish between "n/a", "unknown" or "we don't
care" then add another column called `why_no_judge` or something.

Regards,
Bill Karwin

Re: [fw-db] Zend_Db_Table Issue

On Thu, Feb 24, 2011 at 1:41 PM, Bill Karwin <bill@karwin.com> wrote:

>
> On Feb 24, 2011, at 8:52 AM, David Mintz wrote:
>
> In
>> `events`, my judge_id is signed, and a negative value like -1 means 'not
>> applicable' (to the application) and so forth. At event insertion/update
>> time I will go to great pains to enforce RI, e.g., by locking tables and
>> making sure nobody has deleted judge so-and-so out from under me.
>>
>> What solution would you suggest?
>>
>
> Right -- you can't use -1 if you want DRI, because there is no judge whose
> primary key value is -1.
>
> You should make the judge_id column nullable, and use NULL to mean 'not
> applicable' or 'not assigned'. Then you can declare a foreign key
> constraint to the judges table. A NULL in the foreign key column doesn't
> have to match any row in the referenced table.
>
> You can read more about using NULL in my book "SQL Antipatterns" (
> http://www.pragprog.com/titles/bksqla/), in the chapter "Fear of the
> Unknown."
>
> That said, I think it's weird to delete a row from the judges table
> regardless. Does that mean when a judge retires, you delete his row, and
> the delete cascades to any events that he or she participated in? Doesn't
> that mean destroying a lot of useful historical data? Not to mention
> erasing the legacy of a respectable career in public service?
>
> I would think that in an app like this, you would never actually DELETE a
> row from judges. Instead, you set a `status` attribute for that judge, to
> mark him or her as 'retired' or 'voted out of office' or something. Or else
> set a date field for `end_active_term`. Then code your application logic to
> create new events only for active judges, e.g. those whose `status` is
> 'active', or whose `end_active_term` is either NULL or in the future.
>
> If you don't delete, then you don't need to cascade deletes. :-)
>


Thanks for the helpful observations. The trouble with NULL is that it's too
vague. I have cases where I need something that means "not applicable,"
"unknown," or most often, "we don't care" because the proceeding took place
before the generic duty magistrate whose actual identity really isn't
important, and users don't want to be forced to identify her/him by name.

And you're quite right: deletion will be a rarity in my judges table as well
as most others. But it could happen that one user half-assedly puts in an
inexact duplicate of another row, or otherwise made some mistake, and
someone else comes along and corrects the mistake by deleting it before the
row acquires children, but too late for its id not to appear as a value in
some SELECT menu.

And I do have a de facto boolean 'active' column in this table (it's MySQL)
where 1 means active and 0 means inactive -- retired, deceased, resigned,
etc. Indeed when someone who is known to the app changes hats -- and it
happens -- say from law clerk to prosecutor, prosecutor to judge, they will
not be deleted but made inactive and then they'll be reborn in another row.
I call it reincarnation. Otherwise, yeah, you would trash or falsify your
historical data.

It's really reassuring when someone who knows what he's talking about
suggests you do what you're already doing, so thanks!

Getting back to the first point about NULL, I suppose I could make the data
model even more complicated but I'd of course prefer to keep it as simple as
possible, no more complex than necessary. I'm of course open to more
suggestions, but I think it may be that it's just the challenge of modeling
uncooperative reality in a set of rectangular tables.


--
David Mintz
http://davidmintz.org/
It ain't over:
http://www.healthcare-now.org/

Re: [fw-db] Zend_Db_Table Issue

On Feb 24, 2011, at 8:52 AM, David Mintz wrote:

> In
> `events`, my judge_id is signed, and a negative value like -1 means
> 'not
> applicable' (to the application) and so forth. At event insertion/
> update
> time I will go to great pains to enforce RI, e.g., by locking tables
> and
> making sure nobody has deleted judge so-and-so out from under me.
>
> What solution would you suggest?

Right -- you can't use -1 if you want DRI, because there is no judge
whose primary key value is -1.

You should make the judge_id column nullable, and use NULL to mean
'not applicable' or 'not assigned'. Then you can declare a foreign
key constraint to the judges table. A NULL in the foreign key column
doesn't have to match any row in the referenced table.

You can read more about using NULL in my book "SQL Antipatterns" (http://www.pragprog.com/titles/bksqla/
), in the chapter "Fear of the Unknown."

That said, I think it's weird to delete a row from the judges table
regardless. Does that mean when a judge retires, you delete his row,
and the delete cascades to any events that he or she participated in?
Doesn't that mean destroying a lot of useful historical data? Not to
mention erasing the legacy of a respectable career in public service?

I would think that in an app like this, you would never actually
DELETE a row from judges. Instead, you set a `status` attribute for
that judge, to mark him or her as 'retired' or 'voted out of office'
or something. Or else set a date field for `end_active_term`. Then
code your application logic to create new events only for active
judges, e.g. those whose `status` is 'active', or whose
`end_active_term` is either NULL or in the future.

If you don't delete, then you don't need to cascade deletes. :-)

Regards,
Bill Karwin

Re: [fw-db] Zend_Db_Table Issue

Would it not work if you made judge_id NULL instead of -1?


On 24/02/2011 16:52, David Mintz wrote:
> On Mon, Feb 21, 2011 at 6:44 PM, Bill Karwin<bill@karwin.com> wrote:
>
>> I coded the cascading functionality in Zend_Db_Table. I don't recommend
>> using it for any RDBMS, whether the RDBMS supports DRI or not.
>>
>> It is not possible to implement cascading referential integrity in a safe
>> manner in any application-space code. It's not a matter of the PHP code in
>> Zend_Db_Table being good enough, it's simply not a task that can work
>> outside the database engine. You need to enforce consistency through the
>> RDBMS engine.
>>
> If that's so, I would love to pick your brains about the following.
> (Coincidentally, the application is for tracking things that take place in a
> judicial system, as Rafael's seems to be.) My apologies if this is getting
> OT.
>
> I have a table called events: things that happen in and around court that
> involve language interpreters. Every event has attributes like language_id,
> date, etc, and has has a related judge entity in ALMOST but not quite every
> instance! So there's a table called judges. I am using DRI where I can in my
> events table, e.g:
>
> CONSTRAINT `events_ibfk_2` FOREIGN KEY (`event_type_id`) REFERENCES
> `event_types` (`id`),
> CONSTRAINT `events_ibfk_5` FOREIGN KEY (`location_id`) REFERENCES
> `locations` (`id`),
> CONSTRAINT `events_ibfk_6` FOREIGN KEY (`language_id`) REFERENCES
> `languages` (`id`)
>
> but I can't do something like
>
> CONSTRAINT `events_ibfk_7` FOREIGN KEY (`judge_id`) REFERENCES `judges`
> (`id`)
>
> because there are some exceptional cases, as noted. My solution is to forgo
> DRI and try to enforce referential integrity at the application level. In
> `events`, my judge_id is signed, and a negative value like -1 means 'not
> applicable' (to the application) and so forth. At event insertion/update
> time I will go to great pains to enforce RI, e.g., by locking tables and
> making sure nobody has deleted judge so-and-so out from under me.
>
> What solution would you suggest?
>
> Thanks!
>

Re: [fw-db] Zend_Db_Table Issue

On Mon, Feb 21, 2011 at 6:44 PM, Bill Karwin <bill@karwin.com> wrote:

> I coded the cascading functionality in Zend_Db_Table. I don't recommend
> using it for any RDBMS, whether the RDBMS supports DRI or not.
>
> It is not possible to implement cascading referential integrity in a safe
> manner in any application-space code. It's not a matter of the PHP code in
> Zend_Db_Table being good enough, it's simply not a task that can work
> outside the database engine. You need to enforce consistency through the
> RDBMS engine.
>

If that's so, I would love to pick your brains about the following.
(Coincidentally, the application is for tracking things that take place in a
judicial system, as Rafael's seems to be.) My apologies if this is getting
OT.

I have a table called events: things that happen in and around court that
involve language interpreters. Every event has attributes like language_id,
date, etc, and has has a related judge entity in ALMOST but not quite every
instance! So there's a table called judges. I am using DRI where I can in my
events table, e.g:

CONSTRAINT `events_ibfk_2` FOREIGN KEY (`event_type_id`) REFERENCES
`event_types` (`id`),
CONSTRAINT `events_ibfk_5` FOREIGN KEY (`location_id`) REFERENCES
`locations` (`id`),
CONSTRAINT `events_ibfk_6` FOREIGN KEY (`language_id`) REFERENCES
`languages` (`id`)

but I can't do something like

CONSTRAINT `events_ibfk_7` FOREIGN KEY (`judge_id`) REFERENCES `judges`
(`id`)

because there are some exceptional cases, as noted. My solution is to forgo
DRI and try to enforce referential integrity at the application level. In
`events`, my judge_id is signed, and a negative value like -1 means 'not
applicable' (to the application) and so forth. At event insertion/update
time I will go to great pains to enforce RI, e.g., by locking tables and
making sure nobody has deleted judge so-and-so out from under me.

What solution would you suggest?

Thanks!

--
David Mintz
http://davidmintz.org/
It ain't over:
http://www.healthcare-now.org/

[fw-gdata] Bad request

Please advi
ce...
This code below returns

[code:protected] => 400
[message:protected] => Bad Request

Cannot figure out how to do it, xxx is correct in my code :)

$client = Zend_Gdata_ClientLogin::getHttpClient($email, $password,
Zend_Gdata_Gapps::AUTH_SERVICE_NAME);
$service = new Zend_Gdata_Gapps($client, $domain);

$get =
"https://apps-apis.google.com/a/feeds/emailsettings/2.0/xxx.com/xxx/";

$client->setUri($get);
$client->request('GET');
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Bad-request-tp3322408p3322408.html
Sent from the Zend gdata mailing list archive at Nabble.com.

2011年2月22日星期二

Re: [fw-db] Zend_Db_Table Issue

Good thought Hector, but I do acknowledge the value to clean up
promptly, if not online during a PHP request. I wouldn't let it go a
month.

Another option is that as you delete database rows that reference
associated files, add the filenames to a queue table of
"files_to_delete". If you roll back, these rows are un-inserted, so
it supports ACID.

Then write a script to be invoked by cron, which processes the queue
and removes both the files and the rows from the queue table.

Usually I fall into the camp of "the database is not a queue," but
it's more likely to work if you only have one client (the cron script)
reading this queue.

Regards,
Bill Karwin

On Feb 22, 2011, at 12:17 PM, Hector Virgen wrote:

> Another way to look at it: space is cheap, your time is not. I
> wouldn't
> worry too much about cascading deletes leaving dangling files/rows.
> You may
> be trying to solve a problem that really isn't a problem in the
> first place.
>
> But if you do find that your servers are running out of disk space
> or your
> indexes are becoming too large, write a cron script that does clean
> up once
> a month.
>
> --
> *Hector Virgen*
> Sr. Web Developer
> http://www.virgentech.com
>
>
>
> On Tue, Feb 22, 2011 at 12:11 PM, Bill Karwin <bill@karwin.com> wrote:
>
>>
>> On Feb 22, 2011, at 8:23 AM, Simone Cosci wrote:
>>
>> Il 22/02/2011 0.44, Bill Karwin ha scritto:
>>>
>>>> I coded the cascading functionality in Zend_Db_Table. I don't
>>>> recommend
>>>> using it for any RDBMS, whether the RDBMS supports DRI or not.
>>>>
>>> How can a RDBMS cascading delete unlink files on the filesystem (eg.
>>> images of a product) ?
>>>
>>
>> The correct solution is to unlink the files using application code,
>> but not
>> in a handler for the delete() method of the ORM.
>>
>> What if you unlink files as part of the delete() method, but then
>> you roll
>> back the transaction? You don't get the files back.
>>
>> You should unlink files *only* after you can confirm that the
>> corresponding
>> SQL delete operations have succeeded, and you have committed the
>> transaction
>> for those SQL operations.
>>
>> An alternative is to store files in BLOB columns in the database,
>> instead
>> of on the filesystem. Then you can use DRI to cascade deletes to
>> them, and
>> you can roll back deletes if necessary. It may make your database
>> larger,
>> and make it less convenient to access the files. But you asked for a
>> solution of cascading deletes to files. Storing files in BLOBs
>> works for
>> this requirement.
>>
>> Regards,
>> Bill Karwin
>>
>>

Re: [fw-db] Zend_Db_Table Issue

Another way to look at it: space is cheap, your time is not. I wouldn't
worry too much about cascading deletes leaving dangling files/rows. You may
be trying to solve a problem that really isn't a problem in the first place.

But if you do find that your servers are running out of disk space or your
indexes are becoming too large, write a cron script that does clean up once
a month.

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com

On Tue, Feb 22, 2011 at 12:11 PM, Bill Karwin <bill@karwin.com> wrote:

>
> On Feb 22, 2011, at 8:23 AM, Simone Cosci wrote:
>
> Il 22/02/2011 0.44, Bill Karwin ha scritto:
>>
>>> I coded the cascading functionality in Zend_Db_Table. I don't recommend
>>> using it for any RDBMS, whether the RDBMS supports DRI or not.
>>>
>> How can a RDBMS cascading delete unlink files on the filesystem (eg.
>> images of a product) ?
>>
>
> The correct solution is to unlink the files using application code, but not
> in a handler for the delete() method of the ORM.
>
> What if you unlink files as part of the delete() method, but then you roll
> back the transaction? You don't get the files back.
>
> You should unlink files *only* after you can confirm that the corresponding
> SQL delete operations have succeeded, and you have committed the transaction
> for those SQL operations.
>
> An alternative is to store files in BLOB columns in the database, instead
> of on the filesystem. Then you can use DRI to cascade deletes to them, and
> you can roll back deletes if necessary. It may make your database larger,
> and make it less convenient to access the files. But you asked for a
> solution of cascading deletes to files. Storing files in BLOBs works for
> this requirement.
>
> Regards,
> Bill Karwin
>
>

Re: [fw-db] Zend_Db_Table Issue

On Feb 22, 2011, at 8:23 AM, Simone Cosci wrote:

> Il 22/02/2011 0.44, Bill Karwin ha scritto:
>> I coded the cascading functionality in Zend_Db_Table. I don't
>> recommend using it for any RDBMS, whether the RDBMS supports DRI or
>> not.
> How can a RDBMS cascading delete unlink files on the filesystem (eg.
> images of a product) ?

The correct solution is to unlink the files using application code,
but not in a handler for the delete() method of the ORM.

What if you unlink files as part of the delete() method, but then you
roll back the transaction? You don't get the files back.

You should unlink files *only* after you can confirm that the
corresponding SQL delete operations have succeeded, and you have
committed the transaction for those SQL operations.

An alternative is to store files in BLOB columns in the database,
instead of on the filesystem. Then you can use DRI to cascade deletes
to them, and you can roll back deletes if necessary. It may make your
database larger, and make it less convenient to access the files. But
you asked for a solution of cascading deletes to files. Storing files
in BLOBs works for this requirement.

Regards,
Bill Karwin

Re: [fw-db] Zend_Db_Table Issue

Il 22/02/2011 0.44, Bill Karwin ha scritto:
> I coded the cascading functionality in Zend_Db_Table. I don't
> recommend using it for any RDBMS, whether the RDBMS supports DRI or not.
How can a RDBMS cascading delete unlink files on the filesystem (eg.
images of a product) ?
in some case you should consider to implement your own cascading
operation in your models (imho)
eg.

$depTables = $this->getTable()->getDependentTables();
if (!empty($depTables))
{
/**
* Foreach dependent table instantiate the model
* and call ->delete() on each of them
*/
foreach($depTables as $tableName)
{
$modelName = str_replace('DbTable_', '', $tableName);
$depModel = new $modelName();
$depTable = $depModel->getTable();
$reference =
$depTable->getReference(get_class($table));

switch ($reference['onDelete'])
{
case Zend_Db_Table::CASCADE:

if(count($depTable->info(Zend_Db_Table::PRIMARY)) > 1)
{
$depTable->delete(

$depTable->getAdapter()->quoteInto($reference['columns'][0] . ' = ?', $id)
);
break;
}
$select = $depTable->getAdapter()
->select()
->distinct()

->from($depTable->info(Zend_Db_Table::NAME),
array($reference['refColumns'][0]))

->where($reference['columns'][0] . ' = ?', $id);

$toBeDeleted =
$depTable->getAdapter()->fetchCol($select);

foreach($toBeDeleted as $idToDelete)
$depModel->delete($idToDelete);

break;

case Zend_Db_Table::RESTRICT:
$select = $depTable->getAdapter()
->select()
->distinct()

->from($depTable->info(Zend_Db_Table::NAME),
array($reference['refColumns'][0]))

->where($reference['columns'][0] . ' = ?', $id);

$toBeDeleted =
$depTable->getAdapter()->fetchCol($select);

if (count($toBeDeleted) > 0)
throw new Planet_Exception('Can\'t
delete restricted reference in '.get_class($depTable));

break;

default:
continue;
}
}
}
$n += $row->delete();
$this->notify(__METHOD__, array($primaryKey => $id));

--
________________________________________
Simone Cosci - NextIdea
Software engineering
Planet S.r.l. Sistemi informatici
Via Giorgio Ambrosoli, 39
50018, Scandicci, Firenze, Italy
WEB http://www.planetweb.it
E-Mail s.cosci@nextidea.it
Tel. +39 055 7350271 / 4630416
Fax. +39 055 7351109
Cell. +39 339 8672146
Voip. +39 055 5357896
________________________________________

[fw-mvc] Exceptions in resources

Hi,

Always wondered why not all exceptions caught automatically.
I used to wrap app run call in try{} but I'm not sure if it's good.
So basically, what's the best way to catch all exceptions in ZF and/or
exceptions in custom application resources (which I'm trying to refactor
right now)?

Regards,
Kostia

2011年2月21日星期一

Re: [fw-db] Zend_Db_Table Issue

I coded the cascading functionality in Zend_Db_Table. I don't
recommend using it for any RDBMS, whether the RDBMS supports DRI or not.

It is not possible to implement cascading referential integrity in a
safe manner in any application-space code. It's not a matter of the
PHP code in Zend_Db_Table being good enough, it's simply not a task
that can work outside the database engine. You need to enforce
consistency through the RDBMS engine.

If your application requires cascading referential integrity, use a
storage engine that supports it, such as InnoDB, and declare RDBMS
constraints.

If you use a database engine that doesn't support DRI constraints,
then you can't rely on referential integrity and cannot use cascading
RI operations. Don't try to use application-space cascading DRI. It
doesn't work.

If I have not stated my recommendation plainly enough, feel free to
ask for clarification. :-)

Regards,
Bill Karwin

On Feb 21, 2011, at 8:39 AM, Rafael wrote:

>
> I have read but it says clearly "it is intended" it doesn't says it
> won't work. So I will test with MyISAM engine.
>
> Thanks
>
> Em 21/02/2011 13:27, Christian Proske escreveu:
>> Hy Rafael,
>>
>> have u read this:
>>
>> "Declaring cascading operations in Zend_Db_Table is intended only
>> for RDBMS brands that do not support declarative referential
>> integrity (DRI)."
>>
>> Source:http://framework.zend.com/manual/en/zend.db.table.relationships.html
>>
>> So I think that means it is NOT possible to implement DRI in ZF
>> with InnoDB, because InnoDB supportes DRI.
>>
>> Please correct me if I'm wrong.
>>
>> For more information on how to InnoDB& Foreign Key Constraints:http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
>>
>> Regards,
>> Chris
>>
>> Am 21.02.2011 um 17:12 schrieb Rafael:
>>
>>> > > Well, It doesn't thorows a exception but give that notice,
>>> my code to delete the row is below
>>> > > function deletarID($id) {
>>> > > $processo = $this->find($id);
>>> > > $result = $processo->current()->delete();
>>> > > return $result;
>>> > }
>>> > > > Em 21/02/2011 06:43, Joseph007 escreveu:
>>>> >> Hi,
>>>> >> >> Can you please provide an actual code used by you to
>>>> delete row, that
>>>> >> throws mentioned error?
>>>> >> >> Regards,
>>>> >> Joseph Chereshnovsky
>>>> >> >> On Wed, 2011-02-16 at 01:53 -0200, Rafael wrote:
>>>>> >>> Hello,
>>>>> >>> >>> I don't know if it is the right to ask however i have
>>>>> one issue that
>>>>> >>> nobody else managed to solve it.
>>>>> >>> >>> I'm using zend framework 1.11.3, PHP 5.3 and MySQL 5.1
>>>>> configured with
>>>>> >>> InnoDB engine. I'm trying to make a relationship between
>>>>> two tables
>>>>> >>> to apply cascade deletion but deletes only parental row and
>>>>> return me
>>>>> >>> >>> Notice: Undefined index: numero_atual in
>>>>> >>> C:\htdocs\Advocacia\library\Zend\Db\Table\Abstract.php on
>>>>> line 1197
>>>>> >>> >>> It happens when i try to delete one row from the model
>>>>> >>> Application_Model_ProcessosJudicial , I really can't see
>>>>> anything wrong
>>>>> >>> in the code or...
>>>>> >>> >>> I would be thankful if anyone check it for me
>>>>> >>> >>> class Application_Model_ProcessosJudicial extends
>>>>> Zend_Db_table {
>>>>> >>> >>> protected $_name = "processos_judicial";
>>>>> >>> protected $_dependentTables =
>>>>> array('Application_Model_Partes',
>>>>> >>> 'Application_Model_Andamentos');
>>>>> >>> >>> protected $_referenceMap = array(
>>>>> >>> 'Andamento' => array(
>>>>> >>> 'columns' => array('numero_atual'),
>>>>> >>> 'refColumns' => array('numero_atual'),
>>>>> >>> 'refTableClass' =>
>>>>> 'Application_Model_Andamentos',
>>>>> >>> 'onDelete' => self::CASCADE,
>>>>> >>> 'onUpdate' => self::RESTRICT
>>>>> >>> )
>>>>> >>> );
>>>>> >>> >>> }
>>>>> >>> >>> >>> class Application_Model_Andamentos extends
>>>>> Zend_Db_table {
>>>>> >>> >>> protected $_name =
>>>>> "processos_andamentos_judicial";
>>>>> >>> >>> protected $_referenceMap = array(
>>>>> >>> 'Andamento' => array(
>>>>> >>> 'refTableClass' =>
>>>>> 'Application_Model_ProcessosJudicial',
>>>>> >>> 'refColumns' => array('numero_atual'),
>>>>> >>> 'columns' => array('numero_atual'),
>>>>> >>> 'onDelete' => self::CASCADE,
>>>>> >>> 'onUpdate' => self::RESTRICT
>>>>> >>> )
>>>>> >>> );
>>>>> >>> >>> }
>>>>> >>> >>> My table structure
>>>>> >>> >>> >>> CREATE TABLE IF NOT EXISTS
>>>>> `processos_andamentos_judicial` (
>>>>> >>> `id` int(11) NOT NULL AUTO_INCREMENT,
>>>>> >>> `numero_atual` varchar(30) CHARACTER SET latin1 DEFAULT
>>>>> NULL,
>>>>> >>> `data` datetime DEFAULT NULL,
>>>>> >>> `andamento` varchar(60) CHARACTER SET latin1 DEFAULT
>>>>> NULL,
>>>>> >>> `complemento` varchar(60) CHARACTER SET latin1 DEFAULT
>>>>> NULL,
>>>>> >>> `observacao` longtext CHARACTER SET latin1,
>>>>> >>> `tipo_processo` varchar(45) CHARACTER SET latin1
>>>>> DEFAULT NULL,
>>>>> >>> PRIMARY KEY (`id`),
>>>>> >>> KEY `numero` (`numero_atual`)
>>>>> >>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;
>>>>> >>> >>> CREATE TABLE IF NOT EXISTS `processos_judicial` (
>>>>> >>> `id` int(11) NOT NULL AUTO_INCREMENT,
>>>>> >>> `numero_atual` varchar(30) CHARACTER SET latin1 DEFAULT
>>>>> NULL,
>>>>> >>> `numero_antigo` varchar(30) CHARACTER SET latin1
>>>>> DEFAULT '',
>>>>> >>> `data_distribuicao` date DEFAULT NULL,
>>>>> >>> `orgao` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>>> >>> `circunscricao` varchar(30) CHARACTER SET latin1
>>>>> DEFAULT NULL,
>>>>> >>> `local` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>>> >>> `feito` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>>> >>> `rito` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>>>> >>> `fase` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>>>> >>> `encerrado` tinyint(1) DEFAULT NULL,
>>>>> >>> `encerrado_data` date DEFAULT NULL,
>>>>> >>> `encerrado_motivo` varchar(45) CHARACTER SET latin1
>>>>> DEFAULT NULL,
>>>>> >>> `suspenso` tinyint(1) DEFAULT NULL,
>>>>> >>> `suspenso_data` date DEFAULT NULL,
>>>>> >>> `valor_causa` varchar(30) CHARACTER SET latin1 DEFAULT
>>>>> NULL,
>>>>> >>> `assistencia_gratuita` tinyint(1) DEFAULT NULL,
>>>>> >>> `percentual` varchar(30) CHARACTER SET latin1 DEFAULT
>>>>> NULL,
>>>>> >>> `resumo` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>>> >>> `ultima_modificao` datetime DEFAULT NULL,
>>>>> >>> `criacao` datetime DEFAULT NULL,
>>>>> >>> PRIMARY KEY (`id`),
>>>>> >>> KEY `numero_atual` (`numero_atual`)
>>>>> >>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=43 ;
>>>>> >>> >>> >>>
>>>> >> >> >>
>>> >
>

Re: [fw-db] Zend_Db_Table Issue

The problem was resolved by adding keys to the model

$_primary = array('id','numero_atual');

Anyway

Thank you


Em 21/02/2011 19:00, Joseph007 escreveu:
> It looks like an error.
>
> If you could implement a simplest code to reproduce this issue and file
> a ticket on bug-tracker.
>
> Or just attach ZIP with that code to you message here, that will allow
> anyone to run that code and easy reproduce the error on its development
> machine.
>
> Joseph Chereshnovsky
>
> On Mon, 2011-02-21 at 14:09 -0300, Rafael wrote:
>> It doesn't works with MyISAM also, So the problem is not with the
>> database engine.
>>
>> Anyway thanks,
>>
>> Rafael
>>
>> Em 21/02/2011 13:27, Christian Proske escreveu:
>>> Hy Rafael,
>>>
>>> have u read this:
>>>
>>> "Declaring cascading operations in Zend_Db_Table is intended only for RDBMS brands that do not support declarative referential integrity (DRI)."
>>>
>>> Source: http://framework.zend.com/manual/en/zend.db.table.relationships.html
>>>
>>> So I think that means it is NOT possible to implement DRI in ZF with InnoDB, because InnoDB supportes DRI.
>>>
>>> Please correct me if I'm wrong.
>>>
>>> For more information on how to InnoDB& Foreign Key Constraints: http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
>>>
>>> Regards,
>>> Chris
>>>
>>> Am 21.02.2011 um 17:12 schrieb Rafael:
>>>
>>>> Well, It doesn't thorows a exception but give that notice, my code to delete the row is below
>>>>
>>>> function deletarID($id) {
>>>>
>>>> $processo = $this->find($id);
>>>>
>>>> $result = $processo->current()->delete();
>>>>
>>>> return $result;
>>>> }
>>>>
>>>>
>>>> Em 21/02/2011 06:43, Joseph007 escreveu:
>>>>> Hi,
>>>>>
>>>>> Can you please provide an actual code used by you to delete row, that
>>>>> throws mentioned error?
>>>>>
>>>>> Regards,
>>>>> Joseph Chereshnovsky
>>>>>
>>>>> On Wed, 2011-02-16 at 01:53 -0200, Rafael wrote:
>>>>>> Hello,
>>>>>>
>>>>>> I don't know if it is the right to ask however i have one issue that
>>>>>> nobody else managed to solve it.
>>>>>>
>>>>>> I'm using zend framework 1.11.3, PHP 5.3 and MySQL 5.1 configured with
>>>>>> InnoDB engine. I'm trying to make a relationship between two tables
>>>>>> to apply cascade deletion but deletes only parental row and return me
>>>>>>
>>>>>> Notice: Undefined index: numero_atual in
>>>>>> C:\htdocs\Advocacia\library\Zend\Db\Table\Abstract.php on line 1197
>>>>>>
>>>>>> It happens when i try to delete one row from the model
>>>>>> Application_Model_ProcessosJudicial , I really can't see anything wrong
>>>>>> in the code or...
>>>>>>
>>>>>> I would be thankful if anyone check it for me
>>>>>>
>>>>>> class Application_Model_ProcessosJudicial extends Zend_Db_table {
>>>>>>
>>>>>> protected $_name = "processos_judicial";
>>>>>> protected $_dependentTables = array('Application_Model_Partes',
>>>>>> 'Application_Model_Andamentos');
>>>>>>
>>>>>> protected $_referenceMap = array(
>>>>>> 'Andamento' => array(
>>>>>> 'columns' => array('numero_atual'),
>>>>>> 'refColumns' => array('numero_atual'),
>>>>>> 'refTableClass' => 'Application_Model_Andamentos',
>>>>>> 'onDelete' => self::CASCADE,
>>>>>> 'onUpdate' => self::RESTRICT
>>>>>> )
>>>>>> );
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>> class Application_Model_Andamentos extends Zend_Db_table {
>>>>>>
>>>>>> protected $_name = "processos_andamentos_judicial";
>>>>>>
>>>>>> protected $_referenceMap = array(
>>>>>> 'Andamento' => array(
>>>>>> 'refTableClass' => 'Application_Model_ProcessosJudicial',
>>>>>> 'refColumns' => array('numero_atual'),
>>>>>> 'columns' => array('numero_atual'),
>>>>>> 'onDelete' => self::CASCADE,
>>>>>> 'onUpdate' => self::RESTRICT
>>>>>> )
>>>>>> );
>>>>>>
>>>>>> }
>>>>>>
>>>>>> My table structure
>>>>>>
>>>>>>
>>>>>> CREATE TABLE IF NOT EXISTS `processos_andamentos_judicial` (
>>>>>> `id` int(11) NOT NULL AUTO_INCREMENT,
>>>>>> `numero_atual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> `data` datetime DEFAULT NULL,
>>>>>> `andamento` varchar(60) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> `complemento` varchar(60) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> `observacao` longtext CHARACTER SET latin1,
>>>>>> `tipo_processo` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> PRIMARY KEY (`id`),
>>>>>> KEY `numero` (`numero_atual`)
>>>>>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;
>>>>>>
>>>>>> CREATE TABLE IF NOT EXISTS `processos_judicial` (
>>>>>> `id` int(11) NOT NULL AUTO_INCREMENT,
>>>>>> `numero_atual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> `numero_antigo` varchar(30) CHARACTER SET latin1 DEFAULT '',
>>>>>> `data_distribuicao` date DEFAULT NULL,
>>>>>> `orgao` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> `circunscricao` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> `local` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> `feito` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> `rito` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> `fase` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> `encerrado` tinyint(1) DEFAULT NULL,
>>>>>> `encerrado_data` date DEFAULT NULL,
>>>>>> `encerrado_motivo` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> `suspenso` tinyint(1) DEFAULT NULL,
>>>>>> `suspenso_data` date DEFAULT NULL,
>>>>>> `valor_causa` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> `assistencia_gratuita` tinyint(1) DEFAULT NULL,
>>>>>> `percentual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> `resumo` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>>>> `ultima_modificao` datetime DEFAULT NULL,
>>>>>> `criacao` datetime DEFAULT NULL,
>>>>>> PRIMARY KEY (`id`),
>>>>>> KEY `numero_atual` (`numero_atual`)
>>>>>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=43 ;
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>
>>
>
>
>

Re: [fw-db] Zend_Db_Table Issue

It looks like an error.

If you could implement a simplest code to reproduce this issue and file
a ticket on bug-tracker.

Or just attach ZIP with that code to you message here, that will allow
anyone to run that code and easy reproduce the error on its development
machine.

Joseph Chereshnovsky

On Mon, 2011-02-21 at 14:09 -0300, Rafael wrote:
> It doesn't works with MyISAM also, So the problem is not with the
> database engine.
>
> Anyway thanks,
>
> Rafael
>
> Em 21/02/2011 13:27, Christian Proske escreveu:
> > Hy Rafael,
> >
> > have u read this:
> >
> > "Declaring cascading operations in Zend_Db_Table is intended only for RDBMS brands that do not support declarative referential integrity (DRI)."
> >
> > Source: http://framework.zend.com/manual/en/zend.db.table.relationships.html
> >
> > So I think that means it is NOT possible to implement DRI in ZF with InnoDB, because InnoDB supportes DRI.
> >
> > Please correct me if I'm wrong.
> >
> > For more information on how to InnoDB& Foreign Key Constraints: http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
> >
> > Regards,
> > Chris
> >
> > Am 21.02.2011 um 17:12 schrieb Rafael:
> >
> >> Well, It doesn't thorows a exception but give that notice, my code to delete the row is below
> >>
> >> function deletarID($id) {
> >>
> >> $processo = $this->find($id);
> >>
> >> $result = $processo->current()->delete();
> >>
> >> return $result;
> >> }
> >>
> >>
> >> Em 21/02/2011 06:43, Joseph007 escreveu:
> >>> Hi,
> >>>
> >>> Can you please provide an actual code used by you to delete row, that
> >>> throws mentioned error?
> >>>
> >>> Regards,
> >>> Joseph Chereshnovsky
> >>>
> >>> On Wed, 2011-02-16 at 01:53 -0200, Rafael wrote:
> >>>> Hello,
> >>>>
> >>>> I don't know if it is the right to ask however i have one issue that
> >>>> nobody else managed to solve it.
> >>>>
> >>>> I'm using zend framework 1.11.3, PHP 5.3 and MySQL 5.1 configured with
> >>>> InnoDB engine. I'm trying to make a relationship between two tables
> >>>> to apply cascade deletion but deletes only parental row and return me
> >>>>
> >>>> Notice: Undefined index: numero_atual in
> >>>> C:\htdocs\Advocacia\library\Zend\Db\Table\Abstract.php on line 1197
> >>>>
> >>>> It happens when i try to delete one row from the model
> >>>> Application_Model_ProcessosJudicial , I really can't see anything wrong
> >>>> in the code or...
> >>>>
> >>>> I would be thankful if anyone check it for me
> >>>>
> >>>> class Application_Model_ProcessosJudicial extends Zend_Db_table {
> >>>>
> >>>> protected $_name = "processos_judicial";
> >>>> protected $_dependentTables = array('Application_Model_Partes',
> >>>> 'Application_Model_Andamentos');
> >>>>
> >>>> protected $_referenceMap = array(
> >>>> 'Andamento' => array(
> >>>> 'columns' => array('numero_atual'),
> >>>> 'refColumns' => array('numero_atual'),
> >>>> 'refTableClass' => 'Application_Model_Andamentos',
> >>>> 'onDelete' => self::CASCADE,
> >>>> 'onUpdate' => self::RESTRICT
> >>>> )
> >>>> );
> >>>>
> >>>> }
> >>>>
> >>>>
> >>>> class Application_Model_Andamentos extends Zend_Db_table {
> >>>>
> >>>> protected $_name = "processos_andamentos_judicial";
> >>>>
> >>>> protected $_referenceMap = array(
> >>>> 'Andamento' => array(
> >>>> 'refTableClass' => 'Application_Model_ProcessosJudicial',
> >>>> 'refColumns' => array('numero_atual'),
> >>>> 'columns' => array('numero_atual'),
> >>>> 'onDelete' => self::CASCADE,
> >>>> 'onUpdate' => self::RESTRICT
> >>>> )
> >>>> );
> >>>>
> >>>> }
> >>>>
> >>>> My table structure
> >>>>
> >>>>
> >>>> CREATE TABLE IF NOT EXISTS `processos_andamentos_judicial` (
> >>>> `id` int(11) NOT NULL AUTO_INCREMENT,
> >>>> `numero_atual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
> >>>> `data` datetime DEFAULT NULL,
> >>>> `andamento` varchar(60) CHARACTER SET latin1 DEFAULT NULL,
> >>>> `complemento` varchar(60) CHARACTER SET latin1 DEFAULT NULL,
> >>>> `observacao` longtext CHARACTER SET latin1,
> >>>> `tipo_processo` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
> >>>> PRIMARY KEY (`id`),
> >>>> KEY `numero` (`numero_atual`)
> >>>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;
> >>>>
> >>>> CREATE TABLE IF NOT EXISTS `processos_judicial` (
> >>>> `id` int(11) NOT NULL AUTO_INCREMENT,
> >>>> `numero_atual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
> >>>> `numero_antigo` varchar(30) CHARACTER SET latin1 DEFAULT '',
> >>>> `data_distribuicao` date DEFAULT NULL,
> >>>> `orgao` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
> >>>> `circunscricao` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
> >>>> `local` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
> >>>> `feito` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
> >>>> `rito` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
> >>>> `fase` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
> >>>> `encerrado` tinyint(1) DEFAULT NULL,
> >>>> `encerrado_data` date DEFAULT NULL,
> >>>> `encerrado_motivo` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
> >>>> `suspenso` tinyint(1) DEFAULT NULL,
> >>>> `suspenso_data` date DEFAULT NULL,
> >>>> `valor_causa` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
> >>>> `assistencia_gratuita` tinyint(1) DEFAULT NULL,
> >>>> `percentual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
> >>>> `resumo` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
> >>>> `ultima_modificao` datetime DEFAULT NULL,
> >>>> `criacao` datetime DEFAULT NULL,
> >>>> PRIMARY KEY (`id`),
> >>>> KEY `numero_atual` (`numero_atual`)
> >>>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=43 ;
> >>>>
> >>>>
> >>>>
> >>>
> >>>
> >
>
>
>

[fw-db] plugging oracle in to my zend app

Hello all,

I have written my application to speak with a mySql database. My
understanding of the framework is that it conveniently wraps all the backend
calls and should allow me to simply change some configuration settings in
order to change databases.

I presume this is done in the application.ini file where I previously had
(currently commented out)

;resources.db.adapter = PDO_MYSQL
;resources.db.isDefaultTableAdapter = true
;resources.db.params.charset = "utf8"
;resources.db.params.host = "localhost"
;resources.db.params.username = "root"
;resources.db.params.password = ""
;resources.db.params.dbname = "taw"

I have used this as a guide to pointing to my newly installed Oracle
database (with a new user "myUser")

resources.db.adapter = PDO_OCI
resources.db.params.port = "8081"
resources.db.isDefaultTableAdapter = true
resources.db.params.charset = "utf8"
resources.db.params.host = "localhost"
resources.db.params.username = "myUser"
resources.db.params.password = "myPassword"
resources.db.params.dbname = "xe"

I have also uncommented the following line in my php config file:
extension=php_pdo_oci.dll

As soon as I log in to my application I get the error:

Uncaught exception 'PDOException' with message 'SQLSTATE[HY000]:
pdo_oci_handle_factory: ORA-12537: TNS:connection closed
(ext\pdo_oci\oci_driver.c:579)' in
C:\xampp\htdocs\TAW\library\Zend\Db\Adapter\Pdo\Abstract.php:129

I understand that this could be an Oracle configuration issue, I just want
to rule out the possibility of the problem being on the application side.

Note that my application works fine when connecting to the mySql database.
All params seem to be correct, as well.

Does anyone have any suggestions?

Thanks!
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/plugging-oracle-in-to-my-zend-app-tp3318114p3318114.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-db] Zend_Db_Table Issue

It doesn't works with MyISAM also, So the problem is not with the
database engine.

Anyway thanks,

Rafael

Em 21/02/2011 13:27, Christian Proske escreveu:
> Hy Rafael,
>
> have u read this:
>
> "Declaring cascading operations in Zend_Db_Table is intended only for RDBMS brands that do not support declarative referential integrity (DRI)."
>
> Source: http://framework.zend.com/manual/en/zend.db.table.relationships.html
>
> So I think that means it is NOT possible to implement DRI in ZF with InnoDB, because InnoDB supportes DRI.
>
> Please correct me if I'm wrong.
>
> For more information on how to InnoDB& Foreign Key Constraints: http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
>
> Regards,
> Chris
>
> Am 21.02.2011 um 17:12 schrieb Rafael:
>
>> Well, It doesn't thorows a exception but give that notice, my code to delete the row is below
>>
>> function deletarID($id) {
>>
>> $processo = $this->find($id);
>>
>> $result = $processo->current()->delete();
>>
>> return $result;
>> }
>>
>>
>> Em 21/02/2011 06:43, Joseph007 escreveu:
>>> Hi,
>>>
>>> Can you please provide an actual code used by you to delete row, that
>>> throws mentioned error?
>>>
>>> Regards,
>>> Joseph Chereshnovsky
>>>
>>> On Wed, 2011-02-16 at 01:53 -0200, Rafael wrote:
>>>> Hello,
>>>>
>>>> I don't know if it is the right to ask however i have one issue that
>>>> nobody else managed to solve it.
>>>>
>>>> I'm using zend framework 1.11.3, PHP 5.3 and MySQL 5.1 configured with
>>>> InnoDB engine. I'm trying to make a relationship between two tables
>>>> to apply cascade deletion but deletes only parental row and return me
>>>>
>>>> Notice: Undefined index: numero_atual in
>>>> C:\htdocs\Advocacia\library\Zend\Db\Table\Abstract.php on line 1197
>>>>
>>>> It happens when i try to delete one row from the model
>>>> Application_Model_ProcessosJudicial , I really can't see anything wrong
>>>> in the code or...
>>>>
>>>> I would be thankful if anyone check it for me
>>>>
>>>> class Application_Model_ProcessosJudicial extends Zend_Db_table {
>>>>
>>>> protected $_name = "processos_judicial";
>>>> protected $_dependentTables = array('Application_Model_Partes',
>>>> 'Application_Model_Andamentos');
>>>>
>>>> protected $_referenceMap = array(
>>>> 'Andamento' => array(
>>>> 'columns' => array('numero_atual'),
>>>> 'refColumns' => array('numero_atual'),
>>>> 'refTableClass' => 'Application_Model_Andamentos',
>>>> 'onDelete' => self::CASCADE,
>>>> 'onUpdate' => self::RESTRICT
>>>> )
>>>> );
>>>>
>>>> }
>>>>
>>>>
>>>> class Application_Model_Andamentos extends Zend_Db_table {
>>>>
>>>> protected $_name = "processos_andamentos_judicial";
>>>>
>>>> protected $_referenceMap = array(
>>>> 'Andamento' => array(
>>>> 'refTableClass' => 'Application_Model_ProcessosJudicial',
>>>> 'refColumns' => array('numero_atual'),
>>>> 'columns' => array('numero_atual'),
>>>> 'onDelete' => self::CASCADE,
>>>> 'onUpdate' => self::RESTRICT
>>>> )
>>>> );
>>>>
>>>> }
>>>>
>>>> My table structure
>>>>
>>>>
>>>> CREATE TABLE IF NOT EXISTS `processos_andamentos_judicial` (
>>>> `id` int(11) NOT NULL AUTO_INCREMENT,
>>>> `numero_atual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> `data` datetime DEFAULT NULL,
>>>> `andamento` varchar(60) CHARACTER SET latin1 DEFAULT NULL,
>>>> `complemento` varchar(60) CHARACTER SET latin1 DEFAULT NULL,
>>>> `observacao` longtext CHARACTER SET latin1,
>>>> `tipo_processo` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>>> PRIMARY KEY (`id`),
>>>> KEY `numero` (`numero_atual`)
>>>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;
>>>>
>>>> CREATE TABLE IF NOT EXISTS `processos_judicial` (
>>>> `id` int(11) NOT NULL AUTO_INCREMENT,
>>>> `numero_atual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> `numero_antigo` varchar(30) CHARACTER SET latin1 DEFAULT '',
>>>> `data_distribuicao` date DEFAULT NULL,
>>>> `orgao` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> `circunscricao` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> `local` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> `feito` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> `rito` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>>> `fase` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>>> `encerrado` tinyint(1) DEFAULT NULL,
>>>> `encerrado_data` date DEFAULT NULL,
>>>> `encerrado_motivo` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>>> `suspenso` tinyint(1) DEFAULT NULL,
>>>> `suspenso_data` date DEFAULT NULL,
>>>> `valor_causa` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> `assistencia_gratuita` tinyint(1) DEFAULT NULL,
>>>> `percentual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> `resumo` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> `ultima_modificao` datetime DEFAULT NULL,
>>>> `criacao` datetime DEFAULT NULL,
>>>> PRIMARY KEY (`id`),
>>>> KEY `numero_atual` (`numero_atual`)
>>>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=43 ;
>>>>
>>>>
>>>>
>>>
>>>
>

Re: [fw-db] Zend_Db_Table Issue

I have read but it says clearly "it is intended" it doesn't says it
won't work. So I will test with MyISAM engine.

Thanks

Em 21/02/2011 13:27, Christian Proske escreveu:
> Hy Rafael,
>
> have u read this:
>
> "Declaring cascading operations in Zend_Db_Table is intended only for RDBMS brands that do not support declarative referential integrity (DRI)."
>
> Source:http://framework.zend.com/manual/en/zend.db.table.relationships.html
>
> So I think that means it is NOT possible to implement DRI in ZF with InnoDB, because InnoDB supportes DRI.
>
> Please correct me if I'm wrong.
>
> For more information on how to InnoDB& Foreign Key Constraints:http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html
>
> Regards,
> Chris
>
> Am 21.02.2011 um 17:12 schrieb Rafael:
>
>> >
>> > Well, It doesn't thorows a exception but give that notice, my code to delete the row is below
>> >
>> > function deletarID($id) {
>> >
>> > $processo = $this->find($id);
>> >
>> > $result = $processo->current()->delete();
>> >
>> > return $result;
>> > }
>> >
>> >
>> > Em 21/02/2011 06:43, Joseph007 escreveu:
>>> >> Hi,
>>> >>
>>> >> Can you please provide an actual code used by you to delete row, that
>>> >> throws mentioned error?
>>> >>
>>> >> Regards,
>>> >> Joseph Chereshnovsky
>>> >>
>>> >> On Wed, 2011-02-16 at 01:53 -0200, Rafael wrote:
>>>> >>> Hello,
>>>> >>>
>>>> >>> I don't know if it is the right to ask however i have one issue that
>>>> >>> nobody else managed to solve it.
>>>> >>>
>>>> >>> I'm using zend framework 1.11.3, PHP 5.3 and MySQL 5.1 configured with
>>>> >>> InnoDB engine. I'm trying to make a relationship between two tables
>>>> >>> to apply cascade deletion but deletes only parental row and return me
>>>> >>>
>>>> >>> Notice: Undefined index: numero_atual in
>>>> >>> C:\htdocs\Advocacia\library\Zend\Db\Table\Abstract.php on line 1197
>>>> >>>
>>>> >>> It happens when i try to delete one row from the model
>>>> >>> Application_Model_ProcessosJudicial , I really can't see anything wrong
>>>> >>> in the code or...
>>>> >>>
>>>> >>> I would be thankful if anyone check it for me
>>>> >>>
>>>> >>> class Application_Model_ProcessosJudicial extends Zend_Db_table {
>>>> >>>
>>>> >>> protected $_name = "processos_judicial";
>>>> >>> protected $_dependentTables = array('Application_Model_Partes',
>>>> >>> 'Application_Model_Andamentos');
>>>> >>>
>>>> >>> protected $_referenceMap = array(
>>>> >>> 'Andamento' => array(
>>>> >>> 'columns' => array('numero_atual'),
>>>> >>> 'refColumns' => array('numero_atual'),
>>>> >>> 'refTableClass' => 'Application_Model_Andamentos',
>>>> >>> 'onDelete' => self::CASCADE,
>>>> >>> 'onUpdate' => self::RESTRICT
>>>> >>> )
>>>> >>> );
>>>> >>>
>>>> >>> }
>>>> >>>
>>>> >>>
>>>> >>> class Application_Model_Andamentos extends Zend_Db_table {
>>>> >>>
>>>> >>> protected $_name = "processos_andamentos_judicial";
>>>> >>>
>>>> >>> protected $_referenceMap = array(
>>>> >>> 'Andamento' => array(
>>>> >>> 'refTableClass' => 'Application_Model_ProcessosJudicial',
>>>> >>> 'refColumns' => array('numero_atual'),
>>>> >>> 'columns' => array('numero_atual'),
>>>> >>> 'onDelete' => self::CASCADE,
>>>> >>> 'onUpdate' => self::RESTRICT
>>>> >>> )
>>>> >>> );
>>>> >>>
>>>> >>> }
>>>> >>>
>>>> >>> My table structure
>>>> >>>
>>>> >>>
>>>> >>> CREATE TABLE IF NOT EXISTS `processos_andamentos_judicial` (
>>>> >>> `id` int(11) NOT NULL AUTO_INCREMENT,
>>>> >>> `numero_atual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> `data` datetime DEFAULT NULL,
>>>> >>> `andamento` varchar(60) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> `complemento` varchar(60) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> `observacao` longtext CHARACTER SET latin1,
>>>> >>> `tipo_processo` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> PRIMARY KEY (`id`),
>>>> >>> KEY `numero` (`numero_atual`)
>>>> >>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;
>>>> >>>
>>>> >>> CREATE TABLE IF NOT EXISTS `processos_judicial` (
>>>> >>> `id` int(11) NOT NULL AUTO_INCREMENT,
>>>> >>> `numero_atual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> `numero_antigo` varchar(30) CHARACTER SET latin1 DEFAULT '',
>>>> >>> `data_distribuicao` date DEFAULT NULL,
>>>> >>> `orgao` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> `circunscricao` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> `local` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> `feito` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> `rito` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> `fase` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> `encerrado` tinyint(1) DEFAULT NULL,
>>>> >>> `encerrado_data` date DEFAULT NULL,
>>>> >>> `encerrado_motivo` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> `suspenso` tinyint(1) DEFAULT NULL,
>>>> >>> `suspenso_data` date DEFAULT NULL,
>>>> >>> `valor_causa` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> `assistencia_gratuita` tinyint(1) DEFAULT NULL,
>>>> >>> `percentual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> `resumo` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>>> >>> `ultima_modificao` datetime DEFAULT NULL,
>>>> >>> `criacao` datetime DEFAULT NULL,
>>>> >>> PRIMARY KEY (`id`),
>>>> >>> KEY `numero_atual` (`numero_atual`)
>>>> >>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=43 ;
>>>> >>>
>>>> >>>
>>>> >>>
>>> >>
>>> >>
>>> >>
>> >

Re: [fw-db] Zend_Db_Table Issue

Hy Rafael,

have u read this:

"Declaring cascading operations in Zend_Db_Table is intended only for RDBMS brands that do not support declarative referential integrity (DRI). "

Source: http://framework.zend.com/manual/en/zend.db.table.relationships.html

So I think that means it is NOT possible to implement DRI in ZF with InnoDB, because InnoDB supportes DRI.

Please correct me if I'm wrong.

For more information on how to InnoDB & Foreign Key Constraints: http://dev.mysql.com/doc/refman/5.1/en/innodb-foreign-key-constraints.html

Regards,
Chris

Am 21.02.2011 um 17:12 schrieb Rafael:

>
> Well, It doesn't thorows a exception but give that notice, my code to delete the row is below
>
> function deletarID($id) {
>
> $processo = $this->find($id);
>
> $result = $processo->current()->delete();
>
> return $result;
> }
>
>
> Em 21/02/2011 06:43, Joseph007 escreveu:
>> Hi,
>>
>> Can you please provide an actual code used by you to delete row, that
>> throws mentioned error?
>>
>> Regards,
>> Joseph Chereshnovsky
>>
>> On Wed, 2011-02-16 at 01:53 -0200, Rafael wrote:
>>> Hello,
>>>
>>> I don't know if it is the right to ask however i have one issue that
>>> nobody else managed to solve it.
>>>
>>> I'm using zend framework 1.11.3, PHP 5.3 and MySQL 5.1 configured with
>>> InnoDB engine. I'm trying to make a relationship between two tables
>>> to apply cascade deletion but deletes only parental row and return me
>>>
>>> Notice: Undefined index: numero_atual in
>>> C:\htdocs\Advocacia\library\Zend\Db\Table\Abstract.php on line 1197
>>>
>>> It happens when i try to delete one row from the model
>>> Application_Model_ProcessosJudicial , I really can't see anything wrong
>>> in the code or...
>>>
>>> I would be thankful if anyone check it for me
>>>
>>> class Application_Model_ProcessosJudicial extends Zend_Db_table {
>>>
>>> protected $_name = "processos_judicial";
>>> protected $_dependentTables = array('Application_Model_Partes',
>>> 'Application_Model_Andamentos');
>>>
>>> protected $_referenceMap = array(
>>> 'Andamento' => array(
>>> 'columns' => array('numero_atual'),
>>> 'refColumns' => array('numero_atual'),
>>> 'refTableClass' => 'Application_Model_Andamentos',
>>> 'onDelete' => self::CASCADE,
>>> 'onUpdate' => self::RESTRICT
>>> )
>>> );
>>>
>>> }
>>>
>>>
>>> class Application_Model_Andamentos extends Zend_Db_table {
>>>
>>> protected $_name = "processos_andamentos_judicial";
>>>
>>> protected $_referenceMap = array(
>>> 'Andamento' => array(
>>> 'refTableClass' => 'Application_Model_ProcessosJudicial',
>>> 'refColumns' => array('numero_atual'),
>>> 'columns' => array('numero_atual'),
>>> 'onDelete' => self::CASCADE,
>>> 'onUpdate' => self::RESTRICT
>>> )
>>> );
>>>
>>> }
>>>
>>> My table structure
>>>
>>>
>>> CREATE TABLE IF NOT EXISTS `processos_andamentos_judicial` (
>>> `id` int(11) NOT NULL AUTO_INCREMENT,
>>> `numero_atual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>> `data` datetime DEFAULT NULL,
>>> `andamento` varchar(60) CHARACTER SET latin1 DEFAULT NULL,
>>> `complemento` varchar(60) CHARACTER SET latin1 DEFAULT NULL,
>>> `observacao` longtext CHARACTER SET latin1,
>>> `tipo_processo` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>> PRIMARY KEY (`id`),
>>> KEY `numero` (`numero_atual`)
>>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;
>>>
>>> CREATE TABLE IF NOT EXISTS `processos_judicial` (
>>> `id` int(11) NOT NULL AUTO_INCREMENT,
>>> `numero_atual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>> `numero_antigo` varchar(30) CHARACTER SET latin1 DEFAULT '',
>>> `data_distribuicao` date DEFAULT NULL,
>>> `orgao` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>> `circunscricao` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>> `local` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>> `feito` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>> `rito` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>> `fase` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>> `encerrado` tinyint(1) DEFAULT NULL,
>>> `encerrado_data` date DEFAULT NULL,
>>> `encerrado_motivo` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>>> `suspenso` tinyint(1) DEFAULT NULL,
>>> `suspenso_data` date DEFAULT NULL,
>>> `valor_causa` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>> `assistencia_gratuita` tinyint(1) DEFAULT NULL,
>>> `percentual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>> `resumo` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>>> `ultima_modificao` datetime DEFAULT NULL,
>>> `criacao` datetime DEFAULT NULL,
>>> PRIMARY KEY (`id`),
>>> KEY `numero_atual` (`numero_atual`)
>>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=43 ;
>>>
>>>
>>>
>>
>>
>>
>

Re: [fw-db] Zend_Db_Table Issue

Well, It doesn't thorows a exception but give that notice, my code to
delete the row is below

function deletarID($id) {

$processo = $this->find($id);

$result = $processo->current()->delete();

return $result;
}


Em 21/02/2011 06:43, Joseph007 escreveu:
> Hi,
>
> Can you please provide an actual code used by you to delete row, that
> throws mentioned error?
>
> Regards,
> Joseph Chereshnovsky
>
> On Wed, 2011-02-16 at 01:53 -0200, Rafael wrote:
>> Hello,
>>
>> I don't know if it is the right to ask however i have one issue that
>> nobody else managed to solve it.
>>
>> I'm using zend framework 1.11.3, PHP 5.3 and MySQL 5.1 configured with
>> InnoDB engine. I'm trying to make a relationship between two tables
>> to apply cascade deletion but deletes only parental row and return me
>>
>> Notice: Undefined index: numero_atual in
>> C:\htdocs\Advocacia\library\Zend\Db\Table\Abstract.php on line 1197
>>
>> It happens when i try to delete one row from the model
>> Application_Model_ProcessosJudicial , I really can't see anything wrong
>> in the code or...
>>
>> I would be thankful if anyone check it for me
>>
>> class Application_Model_ProcessosJudicial extends Zend_Db_table {
>>
>> protected $_name = "processos_judicial";
>> protected $_dependentTables = array('Application_Model_Partes',
>> 'Application_Model_Andamentos');
>>
>> protected $_referenceMap = array(
>> 'Andamento' => array(
>> 'columns' => array('numero_atual'),
>> 'refColumns' => array('numero_atual'),
>> 'refTableClass' => 'Application_Model_Andamentos',
>> 'onDelete' => self::CASCADE,
>> 'onUpdate' => self::RESTRICT
>> )
>> );
>>
>> }
>>
>>
>> class Application_Model_Andamentos extends Zend_Db_table {
>>
>> protected $_name = "processos_andamentos_judicial";
>>
>> protected $_referenceMap = array(
>> 'Andamento' => array(
>> 'refTableClass' => 'Application_Model_ProcessosJudicial',
>> 'refColumns' => array('numero_atual'),
>> 'columns' => array('numero_atual'),
>> 'onDelete' => self::CASCADE,
>> 'onUpdate' => self::RESTRICT
>> )
>> );
>>
>> }
>>
>> My table structure
>>
>>
>> CREATE TABLE IF NOT EXISTS `processos_andamentos_judicial` (
>> `id` int(11) NOT NULL AUTO_INCREMENT,
>> `numero_atual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>> `data` datetime DEFAULT NULL,
>> `andamento` varchar(60) CHARACTER SET latin1 DEFAULT NULL,
>> `complemento` varchar(60) CHARACTER SET latin1 DEFAULT NULL,
>> `observacao` longtext CHARACTER SET latin1,
>> `tipo_processo` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>> PRIMARY KEY (`id`),
>> KEY `numero` (`numero_atual`)
>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ;
>>
>> CREATE TABLE IF NOT EXISTS `processos_judicial` (
>> `id` int(11) NOT NULL AUTO_INCREMENT,
>> `numero_atual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>> `numero_antigo` varchar(30) CHARACTER SET latin1 DEFAULT '',
>> `data_distribuicao` date DEFAULT NULL,
>> `orgao` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>> `circunscricao` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>> `local` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>> `feito` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>> `rito` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>> `fase` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>> `encerrado` tinyint(1) DEFAULT NULL,
>> `encerrado_data` date DEFAULT NULL,
>> `encerrado_motivo` varchar(45) CHARACTER SET latin1 DEFAULT NULL,
>> `suspenso` tinyint(1) DEFAULT NULL,
>> `suspenso_data` date DEFAULT NULL,
>> `valor_causa` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>> `assistencia_gratuita` tinyint(1) DEFAULT NULL,
>> `percentual` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>> `resumo` varchar(30) CHARACTER SET latin1 DEFAULT NULL,
>> `ultima_modificao` datetime DEFAULT NULL,
>> `criacao` datetime DEFAULT NULL,
>> PRIMARY KEY (`id`),
>> KEY `numero_atual` (`numero_atual`)
>> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=43 ;
>>
>>
>>
>
>
>

[fw-mvc] Re: Zend_translate in Form

Hi Thomas,


Thomas Weidner wrote:
>
>
> Additionally, when you already set a default translator, you don't need to
> add translation to the element again. Only when you use a textparser to
> extract these strings when you don't have them anywhere else.
>
>

Are there any examples of these textparsers anywhere? I can't seem to find a
lot of information about it anywhere, but it must be a big problem for
anyone with a large international code base. Are there any ZF components
that do this, or is there scope for such a component? Possibly part of
Zend_Tool?

-Johanna
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Zend-translate-in-Form-tp671453p3317118.html
Sent from the Zend MVC mailing list archive at Nabble.com.