Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About CrimpJiggler

  • Rank
    Regular Member
  1. I read a security article a while ago that claimed it is dangerous to browse the web while you are logged into gmail, facebook, whatever because any website can get the profile ID of these accounts if you are logged into them. That sounds like bs to me, but the article seemed relatively legitimate so I'm wondering about this. Can you, with PHP or javascript get the profile ID of social media/whatever accounts a user is logged into?
  2. I just made this procedure which will do for now: DELIMITER $$ CREATE PROCEDURE rearrangeNodes(IN parentId INT) BEGIN DECLARE parentLft INTEGER; SET parentLft = (SELECT lft FROM table WHERE category_id = NEW.parentId); UPDATE `table` SET lft = CASE WHEN lft > parentLft THEN lft + 2 ELSE lft + 0 END, rght = CASE WHEN rght >= parentLft THEN rght + 2 ELSE rght + 0 END WHERE lft >= newLft; END$$
  3. I can't edit my post, I wanna ask a better question. Is there a simple way to make MySQL handle nested hierarchical database tables for you. My table has a parent_id, lft and rght value. CakePHP handles this automatically but does MySQL have built in functionality for that? If not, can anyone point me towards a simple stored procedure to do it? I know what I need to do, just find out whether the parent node is empty or not, if its empty then I expand it by 2, and shift everything to the left and right of it two. If its not empty, then I just shift everything from the start of the parent node to the right. There must be an automatic way to do it though.
  4. I'm using a CRUD system which won't automatically update the lft and rght values of my hierarchical tables when I enter a new row. I don't know what the best way to solve this is, all I can think of is adding a stored procedure to the table so that whenever a new row gets added, the procedure will make sure the lft and rght values get shifted. Is this even possible with stored procedures?
  5. I've played around with CakePHP, then XCrud (a decent CRUD application) but I gave up on both of them, XCrud was great for everything up until it came to managing complicated relational database tables. Anyhow, I'm using wordpress a lot now cuz it lets me stop reinventing the wheel so much and although I was able to integrate XCrud into WordPress as a plugin, I think the best way to go is just transfer my database tables to WordPress tables and display them as custom post types. My time is really limited right now though, is there a plugin/set of plugins I can use to automate the process? To show you what I mean, heres the XCrud list display of one of the tables: thats great because it automatically sets up the CRUD thing and lets you add and edit fields to the table, and doesn't heavily box you into their system but I have a table of plants, one for products, one for pharmacology, one for categories which are all related to each other, and some of them are structured in a tree/nested hierarchy structure so long story short, I need to do advanced searches based on these relations and handle these tree structured tables and CakePHP didn't work out, and XCrud has crappy documentation and isn't popular enough to find good info. So how would you go about transfering this system to WordPress? I'm guessing I need to make custom post types for each table but what I don't yet know is how to transfer the DB tables to WordPress format, how to handle the relationships between each table and how to handle the hierarchical tree structures.
  6. What you said about the difference, I get that. No need to create an instance of an globally if you only need to create it inside your class, but the method I mentioned above does the exact same thing. I never had to add __construct(ExtraObject $ExtraObject) to the constructor, and to instantiate my class and make sure it instantiates the second class, I never had to do $instance = new MyClass(new ExtraClass()); I just put $this->ExtraClass = new ExtraClass(); inside the constructor function itself. I hope theres something I'm missing here because I was hoping this __construct(Object $object); would let me do something new. Theres a problem I need to learn how to solve right now, I do a shitload of extending classes, I've been extending classes in chains and that can become a problem because sometimes the same class gets inherted twice. Another part of this problem is that only classes at the end of the chain have access to all methods, a class further up the chain can't access the class at the bottom because it hasn't extended it.
  7. Why would something in my website suddenly stop working when I haven't edited it in months. I have a website on a free server, which I recently upgraded to a premium account to host my other sites. When I went to that old site today, I get this error: Heres line 162: $array_cartesian = function() use (&$array_cartesian) { but in my experience errors like this are caused by something before the line with the unexpected code, heres the whole class: class colorCombos { public function __construct() { } static public function get_combos() { $colors = array('blue', 'red', 'green'); $array_cartesian = function() use (&$array_cartesian) { $args = func_get_args(); if(count($args) == 0) { return array(array()); } $a = array_shift($args); $c = call_user_func_array($array_cartesian, $args); $r = array(); foreach($a as $v) { foreach($c as $p) { $r[] = array_merge(array($v), $p); } } return $r; }; $combo = $array_cartesian($colors,$colors); $combo_array['code'] = $combo_array['display'] = array_filter( $combo, function (&$row) { return ($row[0] !== $row[1]); } ); $walk_call = function (&$row,$key) { $row = $row[0] . "-" . $row[1]; }; array_walk_recursive( $combo_array['display'], function(&$item,$key) { $item = ucwords($item); } ); array_walk($combo_array['code'],$walk_call); array_walk($combo_array['display'],$walk_call); return $combo_array; } } Its for generating a list of combinations of two objects, in this case colours, so it'll output an array of items like red-blue, blue-green, green-red etc. It was working fine before, I don't know if it was right after upgrading the account that it happened or not, all I know is I didn't do anything myself to cause the error. Could that empty constructor be the problem? I rarely ever use static methods, I used it here just to learn, do I need to make the constructor static too?
  8. Oh yeah sorry, thats what I meant. What I meant about Config, is it I have a class containing properties common to all my classes. I used extend my classes with that Config class. I just learned about traits, this is brilliant, thanks a lot. This will solve my issues with chains of extended classes.
  9. Brilliant explanations, nice one. So inheritence is what happens when I use "class1 extends class2" and inheretence means that every method and property from class2 becomes part of class one, kind of like if I have a function page and add include('functionspage2.php'). But this $__construct(Objectname $ObjectContainerVariable) thing is more like loading an instance of the Battery object into your Device objects instances. Is that it? I'm still a bit confused. The idea I have in mind, how I do it is like this: class Battery { } class Device { public __construct() { $this->battery = new Battery(); } } then that Battery instance is available to all my methods inside the Device class, and any classes that extent Device. Is this what you mean by me making Battery a subclass of Device, rather than Device having a Battery? An issue I have is lets say Device extends say my Config class, if I need to use the $battery instance inside my Config class I can't access it, I have to make a new instance. I've run into plenty issues like that so my method isn't very good, I'm hoping that this other method solves some of those issues for me. I haven't learned about traits yet but will ASAP, they sound interesting. Nice one for the terminology, but I'm still a bit confused about what inheritence and composition is. Is inheretence what happens when I extend one class with another? If so, then I get it. I see that like merging the two classes. Composition I'm guessing is where you add an instance object of a another class to your class so the second classes methods are contained in the $variable holding the instance.
  10. I've been spending long hours learning about classes and their magic methods. I just came across a tutorial which showed a constructor like this: class Device { //... public function __construct(Battery $battery, $name) { // $battery can only be a valid Battery object $this->battery = $battery; $this->name = $name; // connect to the network $this->connect(); } //... } the Battery part instantly caught my attention. Here had previously made a Battery class (and a more complete Device class) but the next thing he did really caught my interest: $device = new Device(new Battery(), 'iMagic'); // iMagic connected echo $device->name; // iMagic what the hell is going on here? Is this another way to include the methods and properties of one class into another class, in order words is this the same thing as: class Device extends Battery I don't think so because this new Battery() thing looks more like its creating an object inside the Device object. Previously the only way I could to that was to type $battery = new Battery() inside one of my methods. But this looks like hes doing something different. Can anyone explain whats going on here? The whole tutorial is here: http://code.tutsplus.com/tutorials/deciphering-magic-methods-in-php--net-13085 in the main Device method he has a premade $battery variable to hold the Battery object. Sometimes I have multiple classes containing functions which I'd like to include in my main class. I can only extend one class, so I usually extent a class containing only properties, no methods. I still don't know what difference making that info class abstract is, I'd appreciate if anyone could tell me. Also I'd love to know what the point in static methods is. I've never used them because I've never seen the point. Is it just to make it easier to call the methods because you don't need to create an object instance to call them? Sorry for the extra questions, the first one is what I'm really wondering about.
  11. I hear CakePHP 3.0 being talked about like its something for the future but I also see that you can download it and there are tutorials for it out already. Is it ready for developmental use, or is it still too early for that?
  12. The first thing I learned after HTML and CSS is PHP. Its my primary language now, but I also use SQL and javascript and XML regularly, and since I use linux, I use bash scripting. The cool thing is they all work hand in hand. I recently learned how to use SQLite too, which is good because it can be accessed directly by javascript. Are there any other languages which would enable me to make new things and combine them with PHP scripts? I was looking into java but the security restrictions on applets make it pointless. Flash actionscript looks good. What about perl? Or ruby? Would they enable me to do things I can't easily do with PHP? I've heard about node.js recently a lot so I'm looking into that. Bash scripting is great, but the only issue is I could only use it on a server owned by myself, commercial servers won't let you execute commands like that. I'm interested in perl, python and java but I'll only learn them if they enable me to do things I can't do (easily) with PHP.
  • 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.