Jump to content

requinix

Administrators
  • Posts

    15,292
  • Joined

  • Last visited

  • Days Won

    436

Everything posted by requinix

  1. Your composition is backwards. Consider if you injected Cat/Dog/Mouse into Animal. It's a simple question but how would you type that property? class Animal { /** * @var ??? */ private $dna; You can't. You'd have to make each animal itself inherit from some "Dna" thing. Which would make this all the more complicated. But if you did composition the other way around, you would have class Cat { /** * @var Animal */ private $animal; Of course this isn't quite inheritance in the normal sense. It's the concept of inheritance but implemented using composition. Actual inheritance would be "class Cat extends Animal" and thus you'd have to somehow get Animal's data directly into Cat. Not sure if Symfony/Doctrine can do that, but if it were custom code then it wouldn't be hard (SELECT * FROM cat JOIN animal...).
  2. Stop searching StackOverflow and start learning how to write software. Getting Started guide
  3. If you copy your code directly into the post editor then our forum will see the spoilers and convert them to HTML. Instead, click the Code <> button in the post editor, copy your code into the popup, and use that to insert into a new post. You should not need to use wordwrap(). If a long post stetches the page then that means the post is not acting like normal HTML is supposed to act. Can you give us a link to a webpage that shows a long post?
  4. Also, that article you linked is absolutely terrible. Stop using that site, and I'm also going to ask you not to link to it in the future.
  5. exit() can terminate all execution, yes. It is almost never appropriate to use.
  6. If those words you wrote were intended to ask about whether your PHP script has to be executed in order for that Javascript to be sent to the client, the answer is yes. Perform obvious validation with Javascript (which you include with the form or in an external .js script), like checking required fields and value formats, then do the same stuff in PHP plus whatever else because you can't trust Javascript validation to be secure. You can use form field attributes like "required" and "pattern" to make the browser do that validation instead of needing Javascript, but in exchange for the convenience you give up most customization of the error messages. Which may be perfectly fine for you.
  7. Okay... Not entirely sure what all that means. Mostly I was asking to see if there was some way to set things up so that you wouldn't actually need that details-control class to begin with. Honestly, I think that could be possible. Take a look at the createdRow callback option.
  8. So, like, this is going into some sort of table, and you want to be able to add columns to list in that table without having to change a whole lot of code? Like I said, fix the query to return only the columns you care about. Want to add a new column? Add it to the query. Really easy. Then when drawing the table or whatever, you can use a simple foreach($row as $column => $value) and output it as you want because $row will only have the columns you care about.
  9. Out of curiosity, what does the details-control class do?
  10. You've come up with a solution, but the only problem I'm hearing is "I'd like to get an array with the id and type columns from my query". If you issue the proper query, which you should be doing anyway because retrieving every column from the table when you only want a couple is wasteful of both time and resources, then you'll get an array with those columns because they're the only ones in there to begin with.
  11. If you only want the id and type fields then why don't you simply SELECT id, type FROM orders
  12. Does it give information about the 500? And I know you say Windows Server, but are you using IIS specifically? (Probably.) If you're using IIS, the issue is likely because IIS's user account does not have access to the files. Which is a good thing. Put your PHP code near the same place where your other website files are.
  13. Can you be more specific about the problems? Any error messages, either from PHP or from your web server, on the screen or in log files? And are you using IIS?
  14. Either that or the docs are misleading. Check for an older version, look for existing code out in the wild to see what it does, see if there's something that points to docblock annotations instead. Or worst case, read the source.
  15. Exactly. If people write the attribute classes, sure. A human being, sure. By PHP? Because Given how new PHP 8 is, it would be really stupid of that third party to not support traditional annotations as well.
  16. Is it fair to say that all apples can be substituted for pears but not all pears can be substituted for apples? I don't know. I'm telling you there is no conversion process because annotations and attributes are two different things. As far as PHP is concerned, docblock annotations are just comments. Just comments. Nothing else. The whole reason those things work is because some library is using reflection to grab the docblock string for a method or property, then parse it for @things. Different libraries parse different ways. Meanwhile attributes are an actual language feature.
  17. They're the same concept, both acting as ways to add additional information to a thing. But they have very different implementations. What they (probably) did (more or less) is reuse the same backend "Route" thing for both annotations and attributes.
  18. If you're going to be prepending data to the file then you're also going to need to deal with file locks. In case two different PHP requests try to update the counter. Obligatory "but you really shouldn't be using a file for this" comment here.
  19. Depends what is reading the docblocks and parsing the annotations. PHP 8's attributes are a completely new thing. There is no compatibility between them and docblock annotations. There is no sort of conversion process to translate between them.
  20. https://https//rblxlimitedz.000webhostapp.com/api.php?id=316 Look at it.
  21. Somewhere in your code you wrote "new Choices(...)". Hopefully you assigned that to a variable, like the example does with "const example =". Call setChoiceByValue("AFG") on that variable.
  22. If you're talking about jshjohnson/Choices then it looks like the setChoiceByValue method is what you need to use. If you aren't talking about that then a link to its website would be nice - though I do recommend reading said website for information beforehand, in case the answer is there already.
  23. What library are you using to make this select/option widget? It should provide an API for you to use where you can tell it which option you want to be selected and it will do the rest of the work for you.
  24. What Javascript code have you written so far, and what happened when you tried it?
  25. There's going to be coupling somewhere, both regarding database structures and what you do in the view. And from a practical standpoint, the database really shouldn't be being revised so much that coupling is a problem. If you don't like passing database models then create and use business models, which look a lot like database models but aren't tied directly to the database. Of course now your views are tied to those models, bringing us right back around to the "stop screwing around with your data structures" argument.
×
×
  • 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.