User Profile

Collapse

Profile Sidebar

Collapse
guillermobytes
guillermobytes
Last Activity: Aug 10 '11, 09:43 PM
Joined: Jan 28 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • guillermobytes
    replied to Weird DirectoryIterator behaviour
    in PHP
    Sorry, I was very tired... The answer is that DirectoryIterat or iterates through the directory contents. So when i ask if the current element in DirectoryIterat or is a directory, except when the directory iterator is pointing at the . and .. directories, the answer will allways be no!
    The right way to do this is to call is_dir($path)
    sorry for stupid post
    See more | Go to post

    Leave a comment:


  • guillermobytes
    started a topic Weird DirectoryIterator behaviour
    in PHP

    Weird DirectoryIterator behaviour

    Hello,

    can someone make light on this please :

    i have a path to a dir:
    Code:
    $path = "/var/www/Tests";
    echo $path;
    the output is :
    Code:
    /var/www/Tests
    when i create a new DirectoryIterat or like this :
    Code:
    $dirIt = new DirectoryIterator($path);
    and ask php if it is a directory, it says its not!
    Code:
    if (!$dirIt->isDir()) {
        echo "This is not
    ...
    See more | Go to post

  • I'm not sure, but i think you should better use your sanitized $myusername variable rather than the $_POST['anything'];
    I don't know how that could be exploited but, i mean, if you already sanitized your variable, better use it...
    See more | Go to post

    Leave a comment:


  • are you sure there are no spaces at the beginning of your script, or anything that would be sent before the header(location ...) is called?

    cookies are sent along with headers, so make sure they are set before headers are sent. And make sure headers are not sent before you think they are... :)

    let me know
    See more | Go to post

    Leave a comment:


  • thanks for replying dlite922,

    as you point out, it would not make sense to share attributes (class variables) between objects, because they need to be able to be different from each other.

    Static attributes are shared between all objects, that's why they are sometimes called class attributes, rather than instance/object attributes.

    But as you may have notice, methods do not change between objects. Let's say...
    See more | Go to post

    Leave a comment:


  • Do parent class share memory with extended classes?

    Hello,

    I was wondering the cost of creating an instance of an extended class.

    By that I mean, if I have classes:
    - A
    - A1 and A2,
    where: A1 and A2 extend class A.

    what do instances A1 and A2 share of their common parent A in memory?

    a) Nothing
    b) Attributes
    c) just Methods
    d) Attributes and Methods

    by that I would like to know what has to be put...
    See more | Go to post
    Last edited by guillermobytes; Jan 24 '11, 12:17 AM. Reason: please edit title to : do same parent class share memory

  • Well i finally found the solution

    Code:
    SELECT mx.maxAge AS maxAge, 
    	cc.childrenCount AS childrenCount, 
    	i.localUrl AS imageLocalUrl, 
    	p.name AS parentName
    FROM (SELECT parentId, 
    			MAX(age) AS maxAge
    		FROM Children 
    		GROUP BY parentId) AS mx
    INNER JOIN (SELECT parentId,
    			COUNT(*) AS childrenCount 
    		   FROM children 
    			GROUP BY parentId) AS cc ON (mx.parentId = cc.parentId)
    ...
    See more | Go to post

    Leave a comment:


  • what i can't figure out how to do, is to get the correct child id, so far what i can get is the correct max age and the parent name.
    See more | Go to post

    Leave a comment:


  • You are right rabbit, it doesn't work!! :S
    So if any one has a hint I'm still interested!
    See more | Go to post

    Leave a comment:


  • guillermobytes
    replied to search value from table by date
    what is the output of the query :
    Code:
    select * from Point_item_master where PointName='ABC'
    ?

    how is the date formatted?

    try copying the date result form the query i show you, then take the date column name and try creating a new query with the date column name and date result in the where clause and see what happens.
    See more | Go to post

    Leave a comment:


  • Ok so i finally wrapped my head around it!

    The query would be :

    Code:
    SELECT p.name AS parentName,
       cp.imgUrl AS imgUrl,
       [B]MAX(c.age)[/B] AS age
    FROM parent AS p
       RIGHT JOIN children AS c ON (p.parentId = c.parentId)
       RIGHT JOIN childrenPictures AS cp ON (c.pictureId = cp.pictureId))
    [B]GROUP BY p.name[/B]
    The secret was to put a max() coupled with a group by.
    Every child that...
    See more | Go to post

    Leave a comment:


  • guillermobytes
    replied to search value from table by date
    have you tried with your date formatted as '2010-01-12'
    See more | Go to post

    Leave a comment:


  • guillermobytes
    replied to search value from table by date
    hi,
    how do you store your dates in mysql : as a string or as a date?
    what does it return if you make the same query without date in the where clause?
    See more | Go to post

    Leave a comment:


  • guillermobytes
    started a topic foreach parent return eldest son's picture

    foreach parent return eldest son's picture

    hello i have 3 tables : parent, children, childrenPicture s

    Table parent
    parentId | name

    Table children
    childId | parentId | pictureId | age

    Table childrenPicture s
    pictureId | imgUrl

    no i would like to return all parent names with their eldest son's picture (only return parents that have children, and only consider children that have pictures)


    so i thought of...
    See more | Go to post

  • thanks Dormilich for your help, but still...
    Code:
    is_writable() // false
    i have a problem with my harddrive and filesystem is corrupted, maybe that is why it does not work.
    I'll try to fix the filesystem corruption and then run it again.

    regards
    See more | Go to post

    Leave a comment:


  • Why is directory with permissions 777 not writable?

    hi there,

    i'm having a problem with a directory under unix (Mac OS X).
    I would like to use
    Code:
    file_put_contents($dir, file_get_contents(...));
    the problem is that the destination directory $dir is not writable.
    ok, so what i did is to chmod 777 $dir.
    so now file permissions are :
    Code:
    ls -l /Users/gui/Desktop/images
    output
    Code:
    drwxrwxrwx  2 gui  staff       68 Nov 20 01:23 images
    and when in...
    See more | Go to post

  • guillermobytes
    started a topic reset array pointer weird behavior
    in PHP

    reset array pointer weird behavior

    Hi everyone,

    I need some help here with a situation where I have an array and a call to reset() or even when assigning that array to another variable the internal pointer does not point to the first element!!!

    I don't know how to debug this..

    the array is an object attribute and it is set from a preg_match_all( ) call.

    i'm sure there are elements in the array... I don't understand :(
    ...
    See more | Go to post

  • guillermobytes
    replied to type hint method/function return value
    in PHP
    I don't understand what you mean when you say : "- how to implement (on the PHP side)? if you return a variable, it could have any type, and not every type can be converted into any other type. (it might not be a huge problem with String, but with object/interface)"
    why should you convert to another type than the one returned? the purpose of restricting the return type, is to make the script crash when the return type is not the one...
    See more | Go to post

    Leave a comment:


  • guillermobytes
    replied to type hint method/function return value
    in PHP
    yes good point,
    however if I find loose types very useful when you declare variables, with functions I don't. It is very helpful to be able to force some type of return in interfaces/abstract classes... this allows to create frameworks where the end developer directly knows what he can do and what he cannot.
    It also reduces the amount of code, because there is no need to make type checks for each method of some interface implementation,...
    See more | Go to post

    Leave a comment:


  • guillermobytes
    replied to type hint method/function return value
    in PHP
    thanks a lot markus!
    well I don't know if this will be very expensive in efficiency, but for coding, I find it easier to explicitly tell in an interface what a method should return, than in documentation or even in the piece of code (where the method is supposed to be called).
    Anyways I'm not an advanced programmer but that's how i feel about it.
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...