2008年7月30日星期三

Re: [fw-db] SQL debug please

This option already exists. Check the manual for the Zend_Db_Profiler.

Best regards
Tobias

2008/7/30 monk.e.boy <john.glazebrook@guava.com>

Hi,

 Would it be possible to mimic how the PEAR::DB can output the SQL it has
generated. Via a 'set debug level' in the code.

 This would be really cool :-)

 Thanks,

monk.e.boy
--
View this message in context: http://www.nabble.com/SQL-debug-please-tp18728846p18728846.html
Sent from the Zend DB mailing list archive at Nabble.com.


[fw-db] SQL debug please

Hi,

Would it be possible to mimic how the PEAR::DB can output the SQL it has
generated. Via a 'set debug level' in the code.

This would be really cool :-)

Thanks,

monk.e.boy
--
View this message in context: http://www.nabble.com/SQL-debug-please-tp18728846p18728846.html
Sent from the Zend DB mailing list archive at Nabble.com.

re[2]: [fw-db] Using the Zend_Db_Table to return referenced row values

>> When I'm developing in PHP (or any other web scripting language) I open
>> another terminal window, run "tail -f" on the Apache error log file,
and
>> leave that running continuously as I test the PHP scripts. If there
are
>> no
>> errors, this monitoring of the error log doesn't move. If there are
>> errors,
>> I see them immediately. Sort of the "old-school" equivalent of an IDE.
>> :-)

Wow. I never heard that one before!!

I just set my php.ini file to show all warnings and errors.

I also use NuSphere which is really really good. I can't recommend it
enough. You browse your site, then click the debug button (in FF toolbar)
and up comes you code with all the variables and stuff set. Brilliant IDE.
Saves hours debugging stuff. It's also really interesting following the code
through all the Zend Framework, the DB code is interesting.

monk.e.boy
--
View this message in context: http://www.nabble.com/re-2-%3A--fw-db--Using-the-Zend_Db_Table-to-return-referenced-row-values-tp18728813p18728813.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-db] Using the Zend_Db_Table to return referenced row values

I have resulted into using the Zend_Db Adapter class: PDO_MYSQL for my
complex joins. The Zend_Db_Table isnt very useful for my complex joins
especially for those that start joining from a lookup table right up to the
parent tables and might involve some cross column joins. Like the one i have
for this query:

//where am joining event.areaid = area.areaid. Zend_Db_Table cant resolve
that!!
SELECT e.eventName, v.VenueName, c.City, e.ToDate,
DATE(e.DateAdded) AS 'DateAdded', e.IsFeatured,
(e.ToDATE < CURDATE()) AS 'Expired'
FROM EventVenue ev LEFT JOIN Event e ON
ev.eventid=e.eventid LEFT JOIN Venue v ON
ev.venueid=v.venueid LEFT JOIN Area a
ON e.areaid=a.areaid LEFT JOIN City c ON
a.cityid=c.cityid GROUP BY e.EventName ORDER BY
e.ToDate DESC;

So i have resulted into encapuslating my sql query directly in my code
rather than doing it the OOP way. It is just not giving me the desired
results. I will keep those models i have that work on direct lookup but for
cases like the above mentioned i think going this route simply solves it

I just have to quote every value to avoid injection.

So this works perfectly for me with no issues whatsoever

//get all events in the db
public function getAllEvents() {

$db = Zend_Registry::get('db');
$sql = 'SELECT e.EventID,e.EventName, v.VenueName, c.City, e.FromDate,
e.IsFeatured, e.DateAdded, e.ToDate FROM EventVenue ev LEFT
JOIN Event e ON ev.eventid=e.eventid LEFT JOIN Venue v ON
ev.venueid=v.venueid LEFT JOIN Area a ON e.areaid=a.areaid LEFT JOIN City c
ON a.cityid=c.cityid GROUP BY e.EventName ORDER BY
e.ToDate DESC;';

$result = $db->query($sql);
$listEvents = $result->fetchAll();
return $listEvents;

}

Thanks


dele454 wrote:
>
> Thanks Bill you have really been a huge help to me. I couldnt agree less
> with your wife. All i have learnt about PHP and ZF as been self thought. I
> have never worked in a development dept before. All i know till date has
> been out of zeal and curiosity. i believe in delving into new territories
> and grounds - they is so much potential in just leaping unto growth. Am a
> firm believer of that.
>
>
> How do you find out the query joinLeftUsing() spills out from all those
> function calls to your query building?
>
>
> Thanks for those tips - much appreciated.
>
>
> Bill Karwin wrote:
>>
>>
>>
>> dele454 wrote:
>>>
>>> i cant remember you suggesting that. Must have been to someone else. Do
>>> I have to check apache's log files for that? Sorry if i sound so naive.
>>> i 'll really love to know how to do this. Instead of posting stuff every
>>> now and then.
>>>
>>
>> Yes, a typical configuration is for PHP errors to be captured in Apache's
>> error log (note the difference between the error log and the access log).
>> Where these files reside depends on your local Apache configuration.
>>
>> When I'm developing in PHP (or any other web scripting language) I open
>> another terminal window, run "tail -f" on the Apache error log file, and
>> leave that running continuously as I test the PHP scripts. If there are
>> no errors, this monitoring of the error log doesn't move. If there are
>> errors, I see them immediately. Sort of the "old-school" equivalent of
>> an IDE. :-)
>>
>> It's not a problem that you don't know certain things. I never fault
>> anyone for not knowing, because everyone has to start somewhere. My
>> wife sums it up nicely, she says, "nothing about computers is
>> 'intuitive'" (she's been a programmer for many years in Oracle PL/SQL,
>> Java, Perl, & PHP).
>>
>> And also I admit the PHP documentation online is not clear about where to
>> find the error output. In fact, I just tried to search for an article on
>> troubleshooting PHP errors to give you some reading, and found very
>> little available. Lots of articles about how to configure PHP to output
>> errors to custom locations, or how to use PHP error-reporting functions,
>> but not much about where the output goes by default.
>>
>> Regards,
>> Bill Karwin
>>
>
>


-----
dee
--
View this message in context: http://www.nabble.com/Using-the-Zend_Db_Table-to-return-referenced-row-values-tp18688983p18728777.html
Sent from the Zend DB mailing list archive at Nabble.com.

re[2]: [fw-db] Using the Zend_Db_Table to return referenced row values

>> Your query is this:

I ask thee, which is easier to read and understand? ::

$sql = <<<EOT


SELECT e.eventName, v.VenueName, c.City
FROM EventVenue ev
LEFT JOIN Event e ON ev.eventid=e.eventid
LEFT JOIN Venue v ON ev.venueid=v.venueid
LEFT JOIN Area a ON e.areaid=a.areaid
LEFT JOIN City c ON a.cityid=c.cityid;

EOT;

---- or ----

$sql = $this->select()->setIntegrityCheck(false)
->from($this, array() )
->joinLeftUsing( array('e'=>'Event'), 'EventId', array('EventName') )
->joinLeftUsing( array('v'=>'Venue'), 'VenueId', array('VenueName') )
->joinLeft( array('a'=>'Area'), 'e.AreaId = a.AreaId', array() )
->joinLeft( array('c'=>'City'), 'a.CityId = c.CityId', array('City') );

Object models are a neat idea, but good god, the code is a mess. It's
starting to look like Perl....

monk.e.boy
--
View this message in context: http://www.nabble.com/re-2-%3A--fw-db--Using-the-Zend_Db_Table-to-return-referenced-row-values-tp18728740p18728740.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-mvc] Implementation question

Hi Jigal,

You could avoid having to write a view script by adding the following to
the action that updates the status (this disables the rendering of a
view script through the viewRenderer action helper):

$this->_helper->viewRenderer->setNoRender(true);

and - if you use layouts as well (disables the layout through the layout
action helper):

$this->_helper->Layout->disableLayout(true);

I usually name my actions something like "updateAjaxAction()" and call
them with the url "/admin/update.ajax". You could also check out the
ContextSwitch action-helper for (a LOT) more documentation on having
your content available in multiple formats/contexts. This would save you
from manually calling disableLayout(), and have your actions work either
with or without being called by XmlHttpRequest calls.

http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.contextswitch

Kind regards,

--
Ramon de la Fuente
Future500 BV

Graaf Janstraat 143
2713 CK ZOETERMEER
tel: +31(0) 79 3164428
fax: +31(0) 84 7160626
mob: +31(0) 6 53443008

@: ramon@future500.nl
w: www.future500.nl


Jigal sanders wrote:
> Hello everyone,
>
> I have a kind of implementation question on how to implement
> something. I will try to explain it over here. It is as follows.
> Currently I am building an online registration system for volunteers
> to subscribe for events. I am now building the admin page and i have a
> way to drill down all the way to one event.
> On this page I can see the details of the event and also the
> subscribers of the event. And this part is what my question is about.
>
> Each line consists of a volunteer who is subscribed for the current
> event. Besides the name and other details of the volunteer also the
> status of the subscription is shown. The admin is able to change the
> status of the subscription by changing the status in a dropdownbox.
> This dropdownbox has a JS event and uses Ajax. The difficult part is
> that I don't really know how to handle this. Because my xmlhttp
> request looks like http://mysite/Admin/Evenement/insert/id/1
> But the current url is http://mysite/Admin/Evenement/all and I
> acutally don't think it's good to make an view script just for this
> one line. The dropdownbox is already defined in /all. So how do I deal
> with this. Can anyone give me some Guidance.
>
> O yes to make it easier to understand look at:
> 1. http://217.149.198.122/ Login with User: Admin pw: Admin
> 2. Then go to Alle Evenementen
> 3. Then click on one of the Id's and then you'll see what I am talking
> about.
>
> Sorry but the site is not multilingual yet ;-)
>
> Kind regards for taking the time to look intop my problem
>
>
> jsanders
>
>

Re: [fw-db] Using the Zend_Db_Table to return referenced row values

Thanks Micah - I am definitely getting there :)

Micah Gersten wrote:
>
> Here:
> http://us2.php.net/manual/en/errorfunc.configuration.php
>
> At the very bottom, it says where the defaults are. This'll help you
> configure, dele454.
>
> Thank you,
> Micah Gersten
> onShore Networks
> Internal Developer
> http://www.onshore.com
>
>
>
> Bill Karwin wrote:
>>
>> dele454 wrote:
>>
>>> i cant remember you suggesting that. Must have been to someone else. Do
>>> I
>>> have to check apache's log files for that? Sorry if i sound so naive. i
>>> 'll really love to know how to do this. Instead of posting stuff every
>>> now
>>> and then.
>>>
>>>
>>
>> Yes, a typical configuration is for PHP errors to be captured in Apache's
>> error log (note the difference between the error log and the access log).
>> Where these files reside depends on your local Apache configuration.
>>
>> When I'm developing in PHP (or any other web scripting language) I open
>> another terminal window, run "tail -f" on the Apache error log file, and
>> leave that running continuously as I test the PHP scripts. If there are
>> no
>> errors, this monitoring of the error log doesn't move. If there are
>> errors,
>> I see them immediately. Sort of the "old-school" equivalent of an IDE.
>> :-)
>>
>> It's not a problem that you don't know certain things. I never fault
>> anyone
>> for not knowing, because everyone has to start somewhere. My wife sums
>> it
>> up nicely, she says, "nothing about computers is 'intuitive'" (she's been
>> a
>> programmer for many years in Oracle PL/SQL, Java, Perl, & PHP).
>>
>> And also I admit the PHP documentation online is not clear about where to
>> find the error output. In fact, I just tried to search for an article on
>> troubleshooting PHP errors to give you some reading, and found very
>> little
>> available. Lots of articles about how to configure PHP to output errors
>> to
>> custom locations, or how to use PHP error-reporting functions, but not
>> much
>> about where the output goes by default.
>>
>> Regards,
>> Bill Karwin
>>
>
>


-----
dee
--
View this message in context: http://www.nabble.com/Using-the-Zend_Db_Table-to-return-referenced-row-values-tp18688983p18727442.html
Sent from the Zend DB mailing list archive at Nabble.com.