Jump to content

cytech

Members
  • Posts

    87
  • Joined

  • Last visited

    Never

Everything posted by cytech

  1. Hey All, I'm working with Amazon's payment system and I have a 'success url' set for amazon that sends them to: mydomain.com/transactions/receivetrans That works just fine, when amazon sends the user back they give off tons of GET variables. One of them being the confirmation location for the security file: https%3A%2F%2Ffps.sandbox.amazonaws.com%2Fcerts%2F090909%2FPKICert.pem This throws my controller for a loop and I get: Error: 403.shtmlController could not be found. If I remove that particular link from the return manually the controller works great and shows the user a thank you message like it should. Controller for that particular view: function receivetrans() { } Just a simple show a page and say thanks... Nothing crazy in there haha. I'm not sure why the above variable would throw off cake, I'm assuming multiple / / but it's not like I can change how amazon sends their info. Any insight from a guru??
  2. That's not a bad idea.. I was reading though and people where saying the overhead of using ON DUPLICATE was a dangerous matter? This true? They where saying if the entry is found ON DUPLICATE removes it and then inserts a new one which in turn is 2 queries. Or am I just over thinking this and I should not worry about that..
  3. Hello, The thing is you have one form for all "edit" submit buttons. So what will happen is it will submit the "last" Num_Pages entry instead of the one you want. What I suggest is removing the "form" from the script and adding a textual link like so. echo "<a href=\"count.php?pages=".$data->Num_Pages."\">Edit ".$data->Num_Pages."</a>"; the above would replace <input type='submit' value='Edit' name='editbutton'></form>
  4. Hey nafetski, Thanks for the ideas. ON DUPLICATE seems like the best option in this situation however I have two unique keys and not just one. REPLACE INTO even though would be a single query, would have its down fall because if the record does exist (which most do) it would take 2 queries to "update" it. So after all is said and done it would be 3 queries for one entry. Even though its faster then doing 3 queries yourself, if I can get it down to a single query on both sides its great. What I have now is doing one insert query into a temporary table (this takes 1-2 seconds if that). I then do an update based from the temporary table to the live table in one update command (this still takes a lot of time - just so many records). Then those that where not updated from the temporary table I insert into the live table. Then truncate temp able and move onto a new file. This works great, except for when you have 30k updates to do haha. Oh well.
  5. Well the suggestions put out have helped overall with performance but when updating 5-10k records its still VERY slow. This is just due to the database. The performance hit isn't with inserts but with the update commands, so I re-did it so I could do the update command in one go instead of doing multiple calls. This seems to have improved performance slightly. However, when doing thousands of records its still very slow. Not sure there's a way around this one. Once again thank you all for your help.
  6. Very interesting... I really appreciate the input mjdamato - I will give this a go.
  7. mysql_query("SELECT * FROM nybygninger WHERE id='".$_GET['itemid']."'"); Be sure to add "." the period before and after the variable. It tells php that you can to add this variable tot he string. Also be sure to use mysql_real_escape_string on your variables when collecting them from _GET, if you don't it will open you up to some nasty sql injection attacks. so: $itemid = mysql_real_escape_string($_GET['itemid']); mysql_query("SELECT * FROM nybygninger WHERE id='".$itemid."'"); Hope that helps
  8. Not sure yet, will attempt it this weekend. Of course, I shall post the results once it is completed.
  9. BOX_INFORMATION_4PRESCRIPTION - looks to be a globally defined variable, check in a config file or "customization" file to see where they are setting the others - such as "BOX_INFORMATION_FAQS".
  10. Check this out: http://www.softwareprojects.com/resources/programming/t-how-to-use-mysql-fast-load-data-for-updates-1753.html
  11. $mailbody .= "Name: ".$_POST['name']."\n"; $mailbody .= "Message: ".$_POST['message']."\n"; $mailbody .= "Phone: ".$_POST['phone']."\n"; $mailbody .= "Email: ".$_POST['email'];
  12. loadata infile... brilliant..
  13. Hey Cags, Agreed... I just figured that out, I switched out the foreach loops and it did run a "hair" faster, not enough to worry about it. So that didn't help. However, when running the import function "without" the database queries it ran through the csv perfectly and decently fast. I put the queries back in and it went to a halt, slow as a snail. So it has to do with the database and queries at this point. With that being said, I need to look at the database and figure out a more appropriate fix. Thank you!
  14. Thank you for your post and for the benchmark code, I will plop that in and see how it looks. It is somewhat essential, users upload their csv files and the system needs to import it into the database. I wonder if there is a solution that upon upload it turns the csv into something that will make importing a lot easier... I will give that a few google searches.
  15. Doing some research and found some benchmarks that state - foreach loops used with large amounts of data are way to inefficient and you should use for loops. Anyone care to back up this claim?
  16. Good Morning, I wrote a small import function for a website of mine and I know there has to be a better way to handle what I'm doing. I'm hoping someone can take my code and make it run a hair faster as it seems to be pretty slow right now. Think anyone can speed this up? What am I doing wrong? or am I doing it right? The below function takes a file(csv) reads the content and imports it into the database, how can I optimize this to run faster and cleaner? function importFile($user_id, $file, $file_id) { if(!file_exists($file)) { return false; } $handle = fopen($file, "rb"); $contents = ''; while (!feof($handle)) { $contents .= fread($handle, 8192); } fclose($handle); if(empty($contents)) { return false; } // grab the items $items = explode("\n", $contents); // if there are items import them. if(is_array($items)) { foreach($items as $key=>$val) { $save_val = $val; $val = explode(",", trim($val)); if(!is_array($val) || sizeOf($val)<=1) { $val = explode("\t", trim($save_val)); if(!is_array($val)) { return false; } } // part number // alt part number // condition // qty // description foreach($val as $inner_key=>$inner_val) { $inner_val = str_replace("\r", "", $inner_val); $val[$inner_key] = str_replace("\"", "", $val[$inner_key]); $val[$inner_key] = trim(mysql_real_escape_string($val[$inner_key])); } if(!empty($val[0]) && strtolower($val[0]) != "part number") { $val[0] = $this->fixPartNumber($val[0]); $val[1] = $this->fixPartNumber($val[1]); // check to see if we need to insert or update $select_sql = "SELECT inventory_id FROM ".TABLE_PREFIX."inventory WHERE inventory_part_number='{$val[0]}' AND user_id={$user_id}"; $result = $this->db->query($select_sql); //echo mysql_error()."<BR><BR>"; if(!$result) { echo "fail"; exit; } if(mysql_num_rows($result) == 0) { // no record, so insert $insert_sql = "INSERT INTO ".TABLE_PREFIX."inventory (inventory_part_number, inventory_alt_part_number, inventory_condition_code, inventory_quantity, inventory_description, last_update, user_id) VALUES ( '{$val[0]}', '{$val[1]}', '{$val[2]}', '{$val[3]}', '{$val[4]}', NOW(), '{$user_id}')"; //echo $insert_sql."<BR><BR>"; $result = $this->db->query($insert_sql); echo "Inserted: ".$val[0]."<br />"; } else { $update_sql = "UPDATE ".TABLE_PREFIX."inventory SET inventory_part_number='{$val[0]}', inventory_alt_part_number='{$val[1]}', inventory_condition_code='{$val[2]}', inventory_quantity='{$val[3]}', inventory_description='{$val[4]}', last_update = NOW() WHERE user_id = {$user_id} AND inventory_part_number = '{$val[0]}'"; //echo $update_sql."<BR><BR>"; $result = $this->db->query($update_sql); echo "Updated: ".$val[0]."<br />"; } } } $update_sql = "UPDATE ".TABLE_PREFIX."file_upload SET file_flag = 1 WHERE file_id=".$file_id." AND user_id=".$user_id; $result = $this->db->query($update_sql); return true; } }
  17. cytech

    Online PDF's

    I appreciate the reply I do agree with your statement in regards to published content, however, you can not make money with a free product. The point is to find a way for my dynamically generated pdf to be viewed by my customers without letting them download it to their pc. It might be impossible, but I doubt it. From my years of developing, there is always a solution, especially when it comes to the internet.
  18. cytech

    Online PDF's

    Hey All, I was wondering if there is a solution out there to display a pdf within a controlled area on the browser, so the user wouldn't be able to download the pdf itself, but still view it on the browser? Any hints would be appreciated
  19. Hey all, Weird issue, when I send out a basic html email it sends out without any errors. Yet, when its received its a blank email - if you view the full source of the email you can see the headers and html code. In my search for an answer I saw someone say its the headers getting confused and the mail client doesn't know how to read it. Has anyone come across this before? Any advice or just a direction would be helpful on how to solve this problem. Its weird for me because I use the same code on my server and it works fine. But on this other server I have this issue. Could it be something on the server? how it sends out the mail? ???
  20. Hey All, I've been looking around to see if I can't find a cms or news system that could handle massive amounts of information like on this site: http://www.environmental-expert.com/ Of course you have your standards like joomla, drupal, and ezpublish - but I'm curious if anyone has any suggestions to a system as used on (http://www.environmental-expert.com/). Either paid or open source. Maybe there is a system out there I haven't heard of yet that's pretty nifty. Any thoughts?
  21. Well figured it out with some help... Cakephp had stored cached versions of the database and was using these cached versions to validate the fields on the form. Hence none of my new fields where used when saving. Gotta love it lol So I guess the moral of the story, checked cached versions of the db since cakephp I guess does this lol.
  22. Okay... I have a bit more info now... If found where they had the global save function (model_php5.php). There is a function in here called hasField(). Now, for some reason the new element I created into the database will not get by this function. So upon further inspection I noticed the hasField function uses $this->_tableInfo within its in_array check. Now, if I var_dump $this->_tableInfo I notice ALL the fields from that table are there but NOT the new one I created, in fact none of the new fields I create show up. My first thought was, great I'm not using the same db or table, but the entry goes in to the right table and db, its just not recognizing the new fields I add. So, with that said is there an array setup somewhere to say include only these types of fields from this table? or anything like that? Any advice is GREATLY appreciated
  23. Hey, Sorry, I mean var_dump, dumping the array of data being sent over to the save function.
  24. Form Helpers, the names match up perfectly. Db field name is "Pd" and form name comes out as "data[user][Pd]" it matches all of the other fields on the form.
  25. Hello, I will try to check out the scaffolding, whats weird is if I dump the data that is being passed to the "save" function, it shows my new variable there fine with a 1 (1=checked). It also saves the other information, so Its not causing a mysql error or anything. Looks like the new field is just being ignored hehe Thanks for some direction, I will try to dump that out and see what happens.
×
×
  • 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.