Hi There -

Am having a little trouble with the following structures. I can't search for them in the manual because the search strips out the punctuation.

  1. Have encountered these: -> and => in conjunction with arrays.
    I think one references a member of an array and the other inserts the value. Not sure which and how that works. How do I search for this in the manual? I think I need to use them.

  2. I'm encountering in db queries some more characters that weren't covered in first-year php. Here's an example from Drupal:

"SELECT nid FROM {node} where uid = %d and type = '%s'";

curly braces? percent signs? They gotta be special, but in what ways?

  1. Finally: function node_save(&$node)

What's the '&' for?

Unfortunately, the manual doesn't play well with these characters and I can't figure out what they mean, so I'm posting them all here in the hopes that someone can give me some advice on how to find these structures in the future so I don't have to bother y'all. I feel like these are basic things I ought to know and whenever I search, I can't find anything meaningful.

So if possible, I'd love to know what these mean, but I'd also like to find out how to find other things like this that I encounter without having to ask. I'm grateful for any help I can get on this.

Thanks

    => is an array operator, associating an array key on the left with an array value on the right.

    -> is an object hierarchy operator, with the parent on the left and the child on the right.

    The braces and percent signs in the example you provided have nothing to do with PHP in this case, they are special SQL characters.

    The & operator in that context indicates that that function argument will be passed by reference to the function instead of by copy.

      The & operator in that context indicates that that function argument will be passed by reference to the function instead of by copy.

      What would be the advantages in doing this?

      Any ideas on how to find out what the mysql characters are about? How do I search for this?

      Thanks for your help! I really appreciate it.

        Capoeirista wrote:

        What would be the advantages in doing this?

        http://www.php.net/manual/en/functions.arguments.php#functions.arguments.by-reference

        Any ideas on how to find out what the mysql characters are about? How do I search for this?

        Thanks for your help! I really appreciate it.

        % is a "wildcard" character used in association with the LIKE keyword to represent 0-n occurrences of any characters.

        From the context, I'll assume the braces are being used to quote "node" to indicate that it is a table or column identifier and not a SQL keyword. Different DBMS's use different identifier quoting methods, so I'm not 100% sure about this, especially taken out of context like that and not knowing what DBMS is being used.

          Am using Drupal. % as a wildcard makes sense. %d and %s are defined earlier as variables.

          Node is an object that owns data in many different tables, referenced by an nid (node id). In the Drupal world, just about everything is a node object.

          You've given me some great direction. Now I can dig more deeply and figure out what I need to do next.

          Thanks for all your help! You're awesome!

            %d = sprintf/printf decimal ( no quotes around the statement indicate it is a number )
            %s = sprintf/printf string ( quotes around the statement indicate it is a string )

              Capoeirista wrote:

              Am using Drupal.

              Right, you mentioned that; what NogDog wasn't sure is what DBMS you are using.

              Anyway, don't forget to mark this thread resolved (if it is).

                Write a Reply...