[fw-general] Error Handling w/ Zend DB

2007-07-25 Thread Ryan Graciano

I'm trying to handle errors appropriately after an insert into MySQL with
Zend_DB and the MySQLi plugin, but I'm having a rough time determining the
cause of the error.

For example, I'd like my application to catch the exception, determine if
the exception occurred due to a unique key violation, and then if so,
identify the column that is causing the violation.  I noticed that the type
of the exception returned is Zend_Db_Statement_Mysqli_Exception, and here's
all of the information I could get out of it -

getCode(): 0
getFile(): D:\Apache224\htdocs\CK\library\Zend\Db\Statement\Mysqli.php
getLine(): 237
getMessage(): Mysqli statement execute error : Duplicate entry '1' for key 1

Does this mean that I need to parse the message to determine exactly what
caused the exception, or is there some other way for me to perform error
handling w/ Zend DB?

Thanks,
- Ryan


[fw-general] quoteInto vs bound parameters

2007-07-20 Thread Ryan Graciano

I've been looking through the Zend_Db documentation, and I'm wondering why
you would ever want to use quoteInto() or quote() as opposed to binding your
parameters in an array.  What's the advantage to quoteInto()/quote()?  Isn't
the separation of data provided by bound parameters always going to be more
secure than attempting to manipulate the strings?  As I understand it, all
statements are prepared anyhow, so why not use more bound parameters?

For example, wouldn't bound parameters always avoid bizarre problems like
unicode SQL injections [http://bugs.mysql.com/bug.php?id=22243], whereas
with quote/quoteInto you're trusting the string parse to get it right?

I'm curious because it looks like relatively few methods (none?) in
Zend_Db_Table support bound parameters.  To use binding, I need to go to the
adapter every time, which makes my Zend_Db_Table class somewhat less
convenient.

I'm new to ZF, so maybe I'm just missing something really obvious here.  I'd
appreciate it if anyone could provide some insight.

Thanks,
- Ryan


[fw-general] ZF changing the cwd

2007-07-18 Thread Ryan Graciano

Sorry for both posts in such a short period of time, but I even though I've
worked around this in my own environment, I thought this post might save
someone else some debug effort.

I'm setting include_path with relative paths in php.ini (and appending to it
in my bootstrap script) and I'm using numerous Zend_* classes all throughout
my code without any trouble, but at one point in my application I hit an
error that indicates Zend_Filter is unable to find Zend_Loader.  This
doesn't make sense because I use Zend_Loader all over the place, including
in my bootstrap script.  After further investigation, it looks like
something is altering my working directory.  I put in an echo getcwd(); at
the beginning of my app, and another right before I access Zend_Filter (for
the 2nd or 3rd time...), and getcwd()  clearly demonstrates that the working
directory has changed -

IINITIAL CWD: D:\Apache224\htdocs\main
Session open...
Reading session...
GC-ing sessions...
Writing session...
PRE-FILTER CWD: D:\Apache224
*Warning*: Zend_Filter::require_once(Zend/Loader.php) [
function.Zend-Filter-require-oncehttp://localhost/CK/function.Zend-Filter-require-once]:
failed to open stream: No such file or directory in *
D:\Apache224\htdocs\CK\library\Zend\Filter.php* on line *88*
*Fatal error*: Zend_Filter::require_once()
[function.requirehttp://localhost/CK/function.require]:
Failed opening required 'Zend/Loader.php'
(include_path='.;./application/controllers;./application/models;./application/config;./application/util;./library')



Some random Googling brought me to this page -
http://www.php.net/ob_start
Some web servers (e.g. Apache) change the working directory of a script
when calling the callback function. You can change it back by e.g.
chdir(dirname($_SERVER['SCRIPT_FILENAME'])) in the callback function.


I'm using Apache, so I did a quick search through the ZF code and I found 12
different occurrences of ob_start.  To narrow it down, I threw echo
statements before each one, and the only one being called is the one in
Zend\Controller\Dispatcher\Standard.php on line 233.  Could this be a
potential defect?  Known issue?  Right now, I'm using absolute paths in my
include_path to work around it.

Thanks,
- Ryan


Re: [fw-general] Error handling with mysqli adapter

2007-07-18 Thread Ryan Graciano

Thanks Eric - this was right on the money.  I found my answer here -

http://www.mail-archive.com/[EMAIL PROTECTED]/msg28759.html

I have a custom session handler that's actually doing the write, and it
looks like PHP is running it after the script is finished executing.  If I
move the same code into a normal block, I see a sane error message.

Thanks again,
- Ryan

On 7/18/07, Eric Coleman [EMAIL PROTECTED] wrote:


On Jul 18, 2007, at 11:15 PM, Ryan Graciano wrote:

 Fatal error: Exception thrown without a stack frame in Unknown on
 line 0

If you search php.internals you'll find a thread about this.  I can't
remember what the exact error message actually means (Positive it was
discussed though).



[fw-general] Using the Redirector helper outside of an Action Controller

2007-07-17 Thread Ryan Graciano

I'm trying to implement a little routing in my bootstrap script (before the
dispatcher starts).  Essentially, under very specific conditions, I need to
alter the controller that is invoked.  I found
Zend_Controller_Action_HelperBroker and the Redirector, but I can't seem to
get them to function outside of an Action Controller.  I've tried various
combinations of code similar to this -

$redirector =
Zend_Controller_Action_HelperBroker::getExistingHelper('Redirector');
$redirector-goto('index');

...but nothing seems to work. I've looked through the docs, and all of the
examples seem to function inside of a controller.  Is there an easy way to
accomplish what I'm trying to do?

Thanks,
- Ryan