Try:
cake 1.1

( uses('model' . DS . 'connection_manager');)

$db = & ConnectionManager::getDataSource('default');

                if (isset($db->error))
                {
                        debug($db->error);
                }






On Aug 3, 8:45 pm, Steveston <[EMAIL PROTECTED]> wrote:
> My Question
>
> (Short version)
>
> Can anybody tell me how to capture MySQL error and pass it to end
> users?
>
> Is there something like $this->set('db_error', some-built-in-function-
> to-get-db-error-msg-as-a-string) in Cake?
>
> PHP has mysql_error function, which returns mysql error msg as a
> string. Is there a counterpart in Cake?
>
> Thanks
>
> (Verbose version)
>
> For example, I have two tables
>
> Table 1 (Entry)
>
> id
> entry_title
> author_id
>
> Table 2 (Author)
>
> id
> author_name
>
> I have set referential integrity rule on these two tables.
>
> Obviously, I cannot add an entry that its author_id does not exist in
> Author table.
>
> If trying to do this in MySQL, I will get a #1452 error, which tells
> me DB cannot add or update a child row because a foreign key
> constraint fails.
>
> What I want is :
>
> 1) (bottom line) Get this #1452 error, pass the error message to users
>
> or
>
> 2) (preferred) Get this $1452 error, rephrase it with the language
> that an ordinary user can understand
>
> To do 2), I think I need a dictionary to translate MySQL's built-in
> error msg to user friendly language, which seems to be a time
> consuming job
>
> So my current expectation is to do 1)
>
> How shall I do?
>
> Thanks,


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to