Jump to content

SchweppesAle

Members
  • Posts

    328
  • Joined

  • Last visited

Everything posted by SchweppesAle

  1. Something like this? if(isset($_REQUEST['task'])) { case 'email_recipients': $result = email_recipients($_REQUEST['member_emails']); //add error checking print '<h3>Emails sent out successfully</h3>'; break; } function email_recipients($email_array) { if(is_array($email_array)) { $headers = //blah; $subject = blah; $from = blah; foreach($email_array as $recip_email) { mail($recip_email, etc); } } } print ' <form action = "" method = "post" >'; $res = mysql_query("SELECT * FROM members") or die(mysql_error()); while ($member = mysql_fetch_array($res)) { print '<input type = "checkbox" name = "member_emails[]" value = "'.$member['email'].'" /> '.$member['email'].' <br/>'; } print ' <input type = "hidden" name = "task" value = "email_recipients" /> <input type = "submit" value = "submit" /> </form>';
  2. Was just wondering why some people choose NOT to make use of static functions when initializing objects via Factory Classes/Containers. What are the benefits of initializing the Factory class when for all intensive purposes, it's only used to initialize new classes, etc? Does this have any impact on Dependency Injection? I'm assuming that it doesn't since that would defeat the purpose. --------- Also, I've noticed that there seems to be an intense stigma within the development community in regard to singletons. Are singletons necessarily a bad thing? What about database objects? One argument I've heard is that this can often impact the flexibility of your application in the event that a new instance of said class needs to be initialized(a second completely separate connection). However, I was thinking that you could simply store these objects within a static member variable in the factory class; leaving the Database Class' __construct public in the event that you need to create that second/third/fourth connection. Wouldn't this resolve the issue?
  3. Not really sure what to make of the following: function pfi_import_xml_menu(pfiImportStruct & $import_struct, SimpleXMLElement $xml_obj, $parent_artifact_id = true, $p_max = null, $disp_order = null) What does the & imply for the first argument?
  4. http://ongopongo.com/maps/google_my_maps_embedding_tool http://www.blogstorm.co.uk/geotargeting-with-php/
  5. Hey, I was just wondering if there's a way to speed up how quickly Linux opens files. I noticed that after having implemented File Caching, the data takes 1/3 times longer to retrieve after having refreshed the page(via fopen). Probably due to the file still being in memory. Are there any apache/linux settings which I can modify which will reduce this time even further. Maybe even keep the (temporary) cached files in memory? hdparm, etc.
  6. Hi, just started experimenting with file caching after reading this article: http://www.rooftopsolutions.nl/blog/107 Aside from when dealing with data which changes frequently, I was wondering if it's ever inappropriate to cache your queries. For example, I have a page with a ridiculous number of queries, some of them have a resulting set which is not nearly as large as others. Page performance increased, just not to the level I had been expecting and I wondering if having Apache read each of these files for data is in fact faster than running a number of queries with only some data being cached.
  7. Something like this? $search = $_POST['search']; if(!is_null($search)) { $replacement = '<font style="background-color: yellow;">'.$search.'</font>'; $string = str_replace($search, $replacement, $string); }
  8. Think this might have done the trick select * FROM ((SELECT events.eventid , events.date , events.name , events.venue , events.venueid , venues.zipcode FROM events INNER JOIN venues ON (events.venueid = venues.venueid) where events.child_category_id='24' and events.parent_category_id='2' and events.status='1' AND venues.zipcode IN ('07087','07086','10272','07093','07030','07047','07097','10130','07307','07096','10125','10072','10099','11249','10161') group by events.name order by date asc) union (SELECT events.eventid , events.date , events.name , events.venue , events.venueid , venues.zipcode FROM events INNER JOIN venues ON (events.venueid = venues.venueid) where events.child_category_id='24' and events.parent_category_id='2' and events.status='1' AND venues.zipcode NOT IN ('07087','07086','10272','07093','07030','07047','07097','10130','07307','07096','10125','10072','10099','11249','10161') group by events.name order by date asc)) AS Table3 w00t, executing Unions. Thanks for the advice man.
  9. alright..here's a test query which I'm trying to run through phpmyadmin. select * FROM ((SELECT events.eventid , events.date , events.name , events.venue , events.venueid , venues.zipcode FROM events INNER JOIN venues ON (events.venueid = venues.venueid) where events.child_category_id='24' and events.parent_category_id='2' and events.status='1' AND venues.zipcode IN ('07087','07086','10272','07093','07030','07047','07097','10130','07307','07096','10125','10072','10099','11249','10161') group by events.name order by date asc) union (SELECT events.eventid , events.date , events.name , events.venue , events.venueid , venues.zipcode FROM events INNER JOIN venues ON (events.venueid = venues.venueid) where events.child_category_id='24' and events.parent_category_id='2' and events.status='1' AND venues.zipcode NOT IN ('07087','07086','10272','07093','07030','07047','07097','10130','07307','07096','10125','10072','10099','11249','10161') group by events.name order by date asc) ) That returns the following: "#1248 - Every derived table must have its own alias " So I tried this: select * FROM ((SELECT events.eventid , events.date , events.name , events.venue , events.venueid , venues.zipcode FROM events INNER JOIN venues ON (events.venueid = venues.venueid) where events.child_category_id='24' and events.parent_category_id='2' and events.status='1' AND venues.zipcode IN ('07087','07086','10272','07093','07030','07047','07097','10130','07307','07096','10125','10072','10099','11249','10161') group by events.name order by date asc) AS Table1 union (SELECT events.eventid , events.date , events.name , events.venue , events.venueid , venues.zipcode FROM events INNER JOIN venues ON (events.venueid = venues.venueid) where events.child_category_id='24' and events.parent_category_id='2' and events.status='1' AND venues.zipcode NOT IN ('07087','07086','10272','07093','07030','07047','07097','10130','07307','07096','10125','10072','10099','11249','10161') group by events.name order by date asc) AS Table2) AS Table3 Which returns: "#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS Table2 ) AS Table3 " Feels like I'm getting close at least
  10. ummmm...I'm really not too familiar with Unions. How would that look exactly?
  11. Yea, I mean the trick is to place all entries which match that venues.zipcodes IN() clause at the top of the resulting set without excluding all the others. Is there anyway of doing this?
  12. Hi, I have the following query which returns all events which fall within a specific list of zip codes. I'd like to know if there's a way of modifying the query so that all entries which don't meet the 'IN' clause are simply displayed after the resulting set. Basically, we're trying to prioritize local events by displaying them first without excluding the others. SELECT events.name , events.time , events.eventid , photos.thumb_file FROM events INNER JOIN performers ON (events.eventid = performers.eventid) INNER JOIN venues ON (events.venueid = venues.venueid) LEFT JOIN photos ON (performers.performerid = photos.performerid) WHERE events.child_category_id = '38' AND venues.zipcode IN ('10017','10261','10259','10174','10164','10170','10168','10087','10179','10167','10163','10166','10178','10154','10022','10158','10103','10124','10150','10173','10197','10171','10176','10165','10152','10157','10156','10043','10055','10175','10016','10020','10111','10126','10155','10104','10105','10153','10112','10151','10095','10138','10129','10010','10160','10172','10159','10018','10036','10185','10102','10149','10109','10177','10001','10108','10090','10019','10117','11120','10106','10118','10162','10122','10021','11109','10120','10060','10121','10119','10101','10107','10099','10276','11249','10123','10072','10125','10044','10113','10069','10011','10114','10003','10211','10199','10082','10133','10023','10009','10110','11222') GROUP BY performers.performer_name ORDER BY time DESC LIMIT 6
  13. I take it this isn't done very often?
  14. Hey, just started working on my first email script. I've managed to open a stream to the mail server using imap_open(). Which function(s) allows me to list all mail subjects and their associated message numbers(ids)? The following is actually pretty similiar to the example listed in the php manual. http://www.php.net/manual/en/function.imap-body.php I'd like to modify it further so that I can target specific messages rather than listing all of them. $check = imap_mailboxmsginfo($mbox); //$num = $check->Recent; $num = $check->Nmsgs; if($num >0) { echo imap_qprint(imap_body($mbox, $num)); }
  15. It might be more useful if I describe exactly what I'm trying to do. We have a huge table containing email addresses(>5million) and I'd like to write a query which singles out duplicate email address entries. The second query(appears?) to work but due to the GROUP BY email clause it won't display all duplicate entries for a specific email address and their associated ids. I'd like to modify it slightly so that it displays all duplicate entries per email address. What would be the correct way of doing this?
  16. hmmm..I actually thought GROUP BY was used to return only unique entries for the specified column. So "GROUP BY email" would only return one entry which contains that specific email. That's why I had assumed GROUP BY id was unnecessary since it's an index. Is this not the case?
  17. Trying to figure out what's wrong with the following query. doesn't work(returns an empty set) SELECT id, email, COUNT(email) AS NumOccurrences FROM huge_email_list GROUP BY id HAVING ( COUNT(email) > 1 ) works just fine SELECT id, email, COUNT(email) AS NumOccurrences FROM huge_email_list GROUP BY email HAVING ( COUNT(email) > 1 )
  18. Alright, this clearly wasn't working Thinking that I might just need to include the GROUP BY email clause in order to count the unique email addresses Still, I was hoping someone could clarify the difference between WHERE and HAVING; I really can't tell the difference.
  19. Hi, I've used the following query to check for any duplicate email addresses in our table. The problem is, I'm not entirely sure what the difference is between both the having and where clauses so I was hoping someone could confirm whether this would work or not. SELECT COUNT(id) AS Quantity FROM huge_email_list GROUP BY email HAVING ( COUNT(email) = 1 ) My concern is that the query will eliminate email addresses which have multiple entries from the total sum(Quantity) entirely rather than counting them as an additional 1 entry. Is this where the Having clause comes into play?
  20. Hi, I need to learn how to write a REGEX which will parse the following strings and return each of their youtube video urls(minus the [youtube= and ], etc). [youtube=http://www.youtube.com/watch?v=something] [youtube=http://www.youtube.com/watch?v=something2] How can this be done?
  21. You're absolutely right. I just picked that up a few minutes ago. I hadn't realized that the value being returned by another function was actually a string and not a float value. Thanks for your help.
  22. Hi, whenever I try inserting a float value of 1,226.37 into a Decimal(10,2) table column; all I see is 1. Is there a reason why this happens? Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.