Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I can't tell you how your code would perform without measuring and testing. I would look for other issues with your code, that would make it a bit more readable/maintanable. For example:</p> <h2>Create smaller methods.</h2> <p>Inside the main method , I see some chunks of code that are well commented. Why not create a method instead of making a huge comment in the main method?</p> <p>For example:</p> <pre><code>// Get The users friends that use this app from facebook $friends = $facebook-&gt;api_client-&gt;fql_query( "SELECT uid, first_name, last_name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=$this-&gt;user" ); return $friends; </code></pre> <p>Would make an interesting</p> <pre><code>functin get_users_friends_from_facebook($facebook){ // Get The users friends that use this app from facebook $friends = $facebook-&gt;api_client-&gt;fql_query( "SELECT uid, first_name, last_name FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1=$this-&gt;user" ); return $friends; } </code></pre> <p>In the same manner,</p> <pre><code>// Get the votes from only the users in that list that voted $result = $this-&gt;db-&gt;query( "SELECT vote, userid FROM user_votes WHERE userid IN ($idstring)" ); </code></pre> <p>Is a good candidate to </p> <pre><code>function get_votes_from_voters(){ // Get the votes from only the users in that list that voted $votes = $this-&gt;db-&gt;query( "SELECT vote, userid FROM user_votes WHERE userid IN ($idstring)" ); } </code></pre> <h2>Give variables meaningful names to the context.</h2> <p><code>$return</code> isn't a good name. Why don't you name it <code>$users_votes</code> for example?</p> <h2>Try to keep the naming convention of your plataform.</h2> <p>Check the apis you're using. Are they using camelCase? Are they using underscores? Try to keep with your libraries and plataform conventions. Check <a href="https://stackoverflow.com/questions/608443/underscore-or-camelcase/608458#608458">this topic</a> for a good reference.</p> <p>And welcome to SO. Your code is fine. Try to read some OO principles, you could even cut more lines of your code. All the simple advices I wrote here are avaiable in a great book named <a href="http://rads.stackoverflow.com/amzn/click/0735619670" rel="nofollow noreferrer">Code Complete</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload