Jump to content

requinix

Administrators
  • Posts

    15,266
  • Joined

  • Last visited

  • Days Won

    431

Everything posted by requinix

  1. Do an outer JOIN on the matching fields, then restrict the results to WHERE some non-nullable field IS NULL - which would only happen if the join failed. LEFT JOIN existing_table t2 ON t2.a = t1.a AND t2.b = t1.b AND... WHERE t2.some_non_nullable_column IS NULLOr you could just put a UNIQUE key on those columns, do an INSERT IGNORE, and let MySQL skip the duplicates for you. Which would be easier.
  2. You don't have to concatenate anything. Just search multiple columns. You can create an index on all the relevant columns to help with that... a rather large index, but would probably be worth it.
  3. You have to make a decision about what constitutes a duplicate record. One that is "already in the database", as you say. I'm guessing project+employee+expenditure+date? Maybe +hours? That information combined creates uniqueness and that's what you search for.
  4. Probably the glaring syntax error. You're also missing a colon.
  5. PHP's normal error output is very minimal. You have Xdebug installed - that's what's doing the orange and exclamation marks. Anyway, set display_errors=off and restart Apache.
  6. requinix

    Query Hangs

    What does EXPLAIN SELECT ORD_Item, ...output?
  7. That means the $page->post_title is an array (I think that's what's going on). So what's in the array? Use something like print_r() or var_dump() or even json_encode() to see, if you're not sure.
  8. Count your {s and }s and see which ones match up with which ones. Proper indentation will also make it much easier to read.
  9. ... How about sorting by the zone?
  10. 1. It looks like you're checking to see if the person exists, and if so, doing the insert. Got that backwards. 2. If this script executes twice at once, with the same person name, then one may both think the person doesn't exist and both try to insert the person. The name is the unique value, right? Make sure your table has a UNIQUE constraint on the name, then do an INSERT IGNORE without bothering to check if the person exists yet. If they do then the insert won't do anything, and if they don't then you've checked and inserted at the same time (which address problem #2).
  11. You'll have to figure out what is taking so long (infinite loop?) in PHP - what the browser says is irrelevant. Nothing in the code you've posted would be at fault so look elsewhere. Maybe AddToCart? The rest of the code you didn't post?
  12. Assuming you don't have a problem getting to the "params" property, The RokCommon_Registry class controls access to its "data" property. An educated guess says that the class will have some method you can call to get the "joomla_articles" value. Get it, unset what you want to unset, then use a corresponding method to set the value back.
  13. That's a bad thing to do. What is the problem you're trying to solve?
  14. There is no "most efficient way". It's like asking what's the most efficient way of opening a door. Or the most efficient way of pushing a button. Your site needs to make sure that people can only do stuff with projects they're involved with, so... you make sure that people can only do stuff with projects they're involved with. Say you've got a page to edit a project. Probably got a project ID in the URL or something. Make sure that you only present the page if the user belongs to the project. As in you do a SQL query to see if there's a record in that third table for the logged-in user and the desired project.
  15. I can't think of anything unique. Not without resorting to something like Java or Flash to get actual computer information. And no, you cannot get the MAC address with Javascript.
  16. I don't know where you are in the book, but the errata (3rd edition) mentions an instance of O(n) on page 26 that's supposed to be O(n^2).
  17. I don't know of an O(n) solution. The "normal" solution would be O(n*m) and a slightly better one would be O(n*log m). $string = preg_filter($pattern, $replacement, $string); // O(1)It's not actually O(1) since you have to consider what that function is doing: loop through the inputs (n) and test the pattern, where the pattern is a set of alternations (m). Thus that's O(n*m), but will be faster than your PHP since it's compiled code. However efficiency isn't determined by runtime but by complexity. The normal solution is like output = "" for each character in input { // O(n) if character is not found in search string { // O(m) output += character } } // O(n*m)The faster solution is sort the search string // O(log m) output = "" for each character in input { // O(n) if character is not found in search string using a binary search { // O(log m) output += character } } // O(n*log m)
  18. ignore_repeated_errors can help with that. Another trick is to use Linux's logrotate: it can keep individual error files small by rotating them: error.log becomes error.log.1 becomes error.log.1.gz and so on. You can have it email you the error file at the same time.
  19. set_error_handler Not quite the same thing but it will let you catch most errors. Not the very fatal ones, though.
  20. Almost. There is a class somewhere named "Table" in the "Cake\ORM" namespace. Odds are it will be in a file Cake\ORM\Table.php (or .class.php or whatever) but that is not always true. Normally to refer to that class in code you would have to write the full path, like $table = new \Cake\ORM\Table();With a use you can tell PHP that any mention of "Table" actually refers to Cake\ORM\Table, so you can write the shorter $table = new Table();
  21. Your browser goes not think that www.xy is a website. It doesn't know the .xy TLD. Use a different domain name, one with a known TLD, or you can probably get away with typing the shorter "www.xy/".
  22. Simply dd-ing won't work if the disk is still in use. Get a boot disc to run a "live" whatever, then dd inside of that. rsync is also popular. Advice: times change. Copy the files you need personally, copy any particular settings you've made for the system and applications, then wait for it to die. Don't worry about making an image of everything. Reinstall stuff as you need it. It's spring cleaning for your computer.
  23. I don't know where valid or obj.office are coming from, but what I meant was a simple document.listingform.office.value == ""
  24. "isset" isn't the thing you're looking for, then. Because the thing exists. Just check for an empty value.
  25. So you're trying to add ? Copy the line for and change it to a capital D.
×
×
  • 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.