trq
Staff Alumni-
Posts
30,999 -
Joined
-
Last visited
-
Days Won
26
Everything posted by trq
-
Funny stuff. You should probably get some facts right first, and then ask your question in a more appropriate place.
-
Maybe if you explained "what" it is your trying to do rather than "how" your trying to do it someone who knows what they are doing could offer a better solution. As it stands, your code is pretty bad I'm sorry to say.
-
Where is your code and the description of where you are stuck?
-
Iterate once through array, starting part way through
trq replied to john-formby's topic in PHP Coding Help
Another option: <?php $a = [1,3,5]; $marker = 1; $new = array_merge(array_splice($a, $marker), array_splice($a, 0, $marker)); foreach ($new as $val) { echo "$val\n"; } -
Static methods are very much frowned upon by most people designing OOP applications. Why? Because they promote tight coupling of components which in turn makes code hard to test. While it may seem to simplify things at first, it just makes larger applications harder to wrok with and more prone to bugs. I would never recommend going down the static path, especially for something like a DBAL.
-
You using classes/functions wrong. Either forget the global keyword exists and pass your data as arguments, or give use global code. Functions, Classes/Methods are designed to encapsulate code. The global keyword is designed to break that encapsulation.
-
The error is pretty straight forward. You are trying to insert 4 values into 2 columns. darkfreaks: If you can answer the question at hand please do, otherwise, leave the thread to people who can. We really don't need every thread around here having you highlight deprecations. Like your security scanning replies, it's going to get pretty old pretty quick.
-
You could also put the class in a namespace which removes this backward compatibility. <?php namespace Railway; class Train { public $train = "e train"; public function train() { echo "I am in the " .$this->train; } } $train = new Train; $train->train(); On a side note, use "public" in place of the older "var" keyword and you should also be explicit about your methods visibility IMO.
-
Look at the logic of your code. The first iteration will produce: SELECT * FROM Users WHERE UserID <= 1 The second: SELECT * FROM Users WHERE UserID <= 2 All the way up to 60. Why not just use: SELECT * FROM Users WHERE UserID <= 60 In the first place? Executing multiple queries when you don't have to is inefficient. You can loop through all results returned. w3schools is terrible. Get yourself a decent book.
-
I'm not sure what your problem is exactly. You can use PHP to create a file uploading quite easily, where exactly are you stuck?
-
Compiling PHP for Windows - Linking Error
trq replied to street9009's topic in PHP Installation and Configuration
Why? -
SELECT GROUP_CONCAT(Part_Name SEPARATOR "','") AS parts FROM Litem GROUP BY Part_Name
-
Why do you want your urls to have "lots of numbers" on the end? What exactly do you plan on doing with these numbers? People don't just tack numbers onto urls for no reason.
-
I don;t think so. It's a very simple pattern.
-
What an unfortunate name for a library, if that is indeed what you are referring to. Ive never heard of it.
-
No ofense, but MVC is a very simple pattern that can easily be implemented without any OOP.
-
Unless class2 is a type of class1 that would be incorrect. The best method is to use dependency inject. Either via the __construct, or as an argument to the method itself. eg; <?php class class2 { protected $class1; public function __construct(class1 $class1) { $this->class1 = $class1; } public function get() { echo $this->class1->str; } } $c2 = new class2(new class1); $c2->get(); [/code] or [code] <?php class class2 { public function get(class1 $class1) { echo $class1->str; } } $c2 = new class2; $c2->get(new class1);
-
Symfony2 without APC, but using an alternative caching method
trq replied to johnsmith153's topic in Frameworks
XCache is an alternative to APC, and in fact Symfony2 has the same mechanisms in place to make use of XCache as it does with APC. Some of these things however need to be setup / configured by the developer. They don't just work out of the box. the same applies to Symfony's use of APC though. -
You will need to know PHP and OOP design principals before you learn any framework.
-
pfff. There is a big difference between knowing HTML and CSS and being able to design. They are different things all together.
-
Post your actual code.