Jump to content

davestewart

Members
  • Posts

    68
  • Joined

  • Last visited

    Never

Everything posted by davestewart

  1. Check it out - a really neat answer appeared on Stack Overflow: http://stackoverflow.com/questions/455800/does-php-feature-short-hand-syntax-for-objects Nice.
  2. Nope. It's not a regexp thing I don't think. Either my server is off, or there's something else up with the htaccess. I'm going to sleep on this one. Thanks for you efforts in the meantime though.
  3. Ah no - that's the PROBLEM! The rewritten URL "tunes" is not being reflected in the links in the page, which are all relative. .htaccess rewrite: Realpath: /files/music/ RewritePath: /tunes/ Page URL: www.domain.com/tunes/ Page links: Link href: ./some-tune.mp3 Supposed file path: www.domain.com/tunes/some-tune.mp3 Actual file path: www.domain.com/some-tune.mp3 So for some reason the "tunes" part of the rewrite is not being reflected in the page links, even though they are relative and the page is showing "tunes" quite happily. Any ideas? Thanks, Dave
  4. That works great for the URL, but now the links in the page are missing the leading "tunes/" - they just appear to be in the web root. What are we missing?
  5. Hi there, I admit, I'm no expert on mod htaccess, in fact I normally use snippets gathered together to make my own Frankenstein's monster of an htaccess. So my question, which I suspect may be based on false assumptions is this: I would like to rewrite "tunes" to "files/music", which I am doing as follows: RewriteEngine On RewriteBase / RewriteRule ^tunes/?$ files/music [PT,L] I was under the impression that this happened internally to the server, and the user would see "tunes" in the URL bar, but Apache would serve the default file in "files/music". However, it looks as if the request is being completely redirected and the page served is "files/music". Is it possible to do what I think it should be doing, or am I just misinformed? Thanks, Dave
  6. As part of a class I'm using to build tables, I've created a general Element class that holds a few properties and methods to output the essential bits of HTML tags, with an easy to use API: // properties $tag $content $class $style $attributes // constructor __construct($content = '', $class = '', $style = '', $attributes = '') // getters html() // wraps the following methods: open() content() close() It's about 50 lines of PHP. It could obviously be sub-classed for things like self closing tags, or specific tag types. My question is, does anyone know if native PHP simple XML would offer faster performance than my nice, simple, lean class? A typical table might hold 20 rows of 6 columns, so 120 or so operations. All my classes are also loaded in the same file. Cheers, Dave
  7. OK, thanks very much everyone for your thoughts. Cheers, Dave
  8. I could use a stored function, but that won't actually affect the efficiency of the call will it? It will just package the call into something accessible. I was more interested in the actual performance benefits of one method over the other
  9. Well, I have a hierarchy of tables something like this: users users_companies companies services invoices items So say I query something like this: get all items for all unpaid invoices for company x (in the past 6 months) for user y That makes quite a few joins as everything is perfectly normalised. But I could include a reference to the company in each invoice, or even item table, which would save me deriving the company by JOINing up the chain to : services companies users_companies (users_companies is a relationship table as users can potentially belong to many companies). Does that make sense?
  10. I'm quite the database intermediate, which could be a dangerous thing (!) so I thought I'd ask some questions here first. I've got a range of tables in my application, and for most of my queries I need to do one or more JOINs. I have one particular query which will JOIN across 5 tables, and due to the way I'm about to allow all users to now belong to more than one group, I have to add a 6th (relationship) table to this (and most other) queries. The thing is, quite a few of the multiple JOIN series could be omitted if I just added a kind of "shortcut" column (that effectively give me the same information as the JOINs) to one of the right-hand tables, and I'd be able to do quite simple queries. Once new entries have been inserted into the table the data in this new entry will never change, so, my question is, now that all the queries are becoming quite complex, how to optimize both the code and the performance? Do I stick with JOINs and retain full normalisation? Do I start using a VIEW (I'm new to views)? Or do I add this new column and just start querying one or possibly two tables max rather than a hefty series of JOINs each time? I realise that there will be a minute level of redundancy with the last method, but it it worth it at the expense of cheaper (I presume) DB calls? At the moment the tables have a few hundred rows, but ultimately I expect them to have a few hundred thousand. Your thoughts would be really valuable, thanks. Cheers, Dave
  11. Yeah, that's what I thought. I will have to find out why the hell they are on in the first place. Thanks for your input, it was really quick and most reassuring. Cheers, Dave
  12. You know, I had the exact same thought after I sent the mail, and they are indeed on! I've never had a problem with them before, but that's because I've always specified my own host, and this server was setup by someone else. Are they on by default or something?
  13. I've an application where I'm cumulatively adding to the $_SESSION variable as the user completes different actions on the pages. To cut to the root of the matter, I have a session key called 'message', ($_SESSION['message']) which stores a bunch of data to do with an email message. Later in the application, on another page, I have a simple page variable $message which stores a message to present to the user regarding the result of an entirely unrelated process. The crazy thing is, the session variable is being overwritten by the page variable, but NOWHERE in my script have I asked it to do this! Sure, I'm starting the session on page load to access some other data, but nowhere do I mix these two up. Does anyone have any idea what is going on? I'm on PHP 5.2.9. Thanks, Dave
  14. OK - final update to the app: I've now added a selection of 12 custom fonts, of varying sizes and styles, full punctuation and European character set for most of them. http://www.keyframesandcode.com/code/development/comment-headings/ I can't really see it needing anything else, so I think that's it for now. Enjoy!
  15. Glad you guys might find it useful. I'll be making another update in a week or so, with a method to use your own custom fonts, so check back then...
  16. Yeah I know. It's not happy in FF3 on a PC either, but it's fine inside an IDE!
  17. I thought it might be helpful to briefly show the comparison between a comment-headered file and a normal file, and how it's easier to skim through the one with comment headings: A file with comment headings. A file with normal text-based headings. And no, it doesn't affect headers.
  18. Hi Neil, It's certainly not supposed to replace JavaDoc commenting, or any other documentation for that matter! All it is, is a large visual reference to areas of your script, so when you're scrolling through large (or even small) scripts you can immediately tell which section you're in. The point is with simple characters -, =, * etc, there's only so much emphasis you can make to a heading, and it's often a lot of legwork. This is just a tool to make that easier. You don't have to stick to headings like "Private Methods", you could have "Front end", "File tasks", "Notes", whatever you like.
  19. I wrote a small Flash app last year to help me out with better-organising and navigating my code called Comment Headings, and I've just updated it. It basically allows you to type in section titles and have them be produced as ASCII art style headings, which makes it much easier to navigate scripts, as it's very easy to see what's where. For example: // ------------------------------------------------------------------------------------------------------------------------ // // ██████ ██ ██ ██ ██ ██ ██ ██ // ██ ██ ██ ███ ███ ██ ██ ██ // ██ ██ ████ ██ ██ ██ █████ █████ █████ ███████ █████ █████ █████ █████ █████ █████ // ██████ ██ ██ ██ ██ ██ ██ ██ ██ ██ █ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ // ██ ██ ██ ██ ██ █████ ██ █████ ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ █████ // ██ ██ ██ ███ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ // ██ ██ ██ ███ █████ ████ █████ ██ ██ █████ ████ ██ ██ █████ █████ █████ // // ------------------------------------------------------------------------------------------------------------------------ // Private Methods private function doSomething() { // function body } private function doSomethingElse() { // function body } // etc It now has options to let you fully customise the input and output using an XML preferences file. For example, you could set up different input headings (Variables, Methods, Initialize, etc) depending on whether you were building class or page code, or you could set up different comment delimiters depending on whether you were coding PHP or VB or something else. If you're using something like Eclipse, then it may not be as useful, but if organising code in a more basic editor, I find I can't work without it now! Test, use, and download it from here: http://www.keyframesandcode.com/code/development/comment-headings/ Cheers, Dave
  20. I want to use XSLT to generate HTML pages from XML files, then use mod_rewite to have them masquerade as static pages. The reason I'm doing this is a Flash site I'm working on has all its data come from flat XML files, but as you probably know Flash is not indexable by search engines, so I want to create an HTML sub-site that is indexable, then use meta-refresh to take the user to the main Flash site.a So I have a couple of questions: 1) Is this possible? 2) Is this a good idea - ie, will Google happily index the HTML pages, or will it ignore all my hard work? Thanks for reading, Cheers, Dave
  21. isset($var) ? $var : '' You're just executing the expression without assigning its result to a variable. $result = isset($var) ? $var : ''
  22. Hey aschk, Actually image_num is a photographer-unique image identifier that each photographer can use to reference their own images. So Dave Stewart might say "I'll have image_nums 1, 2 and 10" as opposed to "I'll have image_ids 1021, 1021 and 1030". It's more the case that I don't need the (redundant) globally-unique image_id, as there will NEVER be a time when an image needs to be referenced outside the context of a photographer. It will always be (for example) photographer 7 and image 10, rather than just image 1030. Anyway - thanks for all the input. It's very, very much appreciated! Still not sure how I could have asked the question in a more succinct way (let me know if you think of anything), but glad we got there in the end. Cheers!! Dave
  23. OK - I'm really starting to get this JOINS thing now. So I could have written the whole thing using WHERE clauses in theta style, but this ANSI style (have I got that right!?) requires the extra WHERE clause to complete the requirements of the set-theory stuff. Update: Ah - I see you added the WHERE clause to the JOIN. I didn't realise you could do that!
  24. Crikey - I've done it! I think... I just added 2 WHERE clauses. Can you check my logic? [pre] SELECT cs.photographer_id, cs.collection_id, cs.name, im.image_id, im.image_num, im.file_name FROM collections_map cm JOIN collections cs ON cm.collection_id = cs.collection_id JOIN images im ON cm.image_num = im.image_num WHERE cs.photographer_id = 2 AND im.photographer_id = cs.photographer_id AND im.image_num = cm.image_num ORDER BY collection_id, file_name[/pre] Which results in this dataset: [pre] photographer_id collection_id name image_id image_num file_name 2 2 Collection A 4 1 image 1.jpg 2 2 Collection A 5 2 image 2.jpg 2 2 Collection A 6 3 image 3.jpg[/pre]
  25. Hey there, Yeah - your SELECT worked just fine, but if you check back - I had already built the same statement and, as you have proved as well, this works. However, it works on the premise that each image has a globally unique image_id, in addition to it's photographer-unique image_num (a job requirement). I want to get of the globally unique id and use both the photographer_id and the image_num to the same effect.
×
×
  • 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.