Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>I have written a php code which will get one id from database and using that id it will use some API's provided by other websites and generate a page. here my question is where this generated page will occupy the space on the server or on the client machine?</p> </blockquote> <p>The generated page will occur on the client if you only fetch one id from your database. For this you could first do a <a href="http://api.jquery.com/jQuery.get/" rel="nofollow">jquery.ge</a>t to fetch id from your server. Next you could get data from other API's using JSONP(JSON with padding). But for this to work the API's off course need to support JSONP, because the javascript clients can't fetch data using jquery.get because of <a href="http://en.wikipedia.org/wiki/Same_origin_policy" rel="nofollow">same origin policy</a>, but lucky JSONP can be used for that. Finally you could just easily append data to the <a href="http://en.wikipedia.org/wiki/Document_Object_Model" rel="nofollow">DOM</a> using <a href="http://api.jquery.com/html/" rel="nofollow">.html</a>. You should be carefull doing this with other API's and need to be sure these are safe API's because else you would be vulnerable to XSS. If you are not certain you should use <a href="http://api.jquery.com/text/" rel="nofollow">.text</a> instead.</p> <blockquote> <p>should i store all data for that API in our MySQL-database.</p> </blockquote> <p>It depends if the API's do provide JSONP.</p> <blockquote> <p>what will make it fast &amp; safe...</p> </blockquote> <h2>Fast</h2> <ol> <li><a href="http://en.wikipedia.org/wiki/PHP_accelerator" rel="nofollow">APC</a> to cache compiled bytecode. This will speed up your website tremendously without even changing a single line in your code-base.</li> <li>in memory database as redis or memcached. You can also use APC to store data in memory. This will speed up your website tremendously, because touching the disc(spinning the disc to right sector, etc) is very expensive and using memory is very fast.</li> <li>The <a href="http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html" rel="nofollow">No-Framework approach</a> will make your site fast, because PHP is <a href="http://en.wikipedia.org/wiki/Dynamic_programming_language" rel="nofollow">dynamic language</a> you should try to do as little as possible.</li> <li>Tackle low hanging fruit only. Remember that "Premature optimization is the root of all evil". Rasmus Lerdorf teaches you how to do this in this video <a href="http://www.archive.org/details/simple_is_hard" rel="nofollow">Simple is Hard from DrupalCon 2008</a>. The slides are available at <a href="http://talks.php.net/show/drupal08" rel="nofollow">PHP's talks section</a> </li> </ol> <h2>Safe</h2> <ol> <li><a href="http://en.wikipedia.org/wiki/SQL_injection" rel="nofollow">Read up OWASP top 10</a></li> <li>Protect against <a href="http://en.wikipedia.org/wiki/Cross-site_scripting" rel="nofollow">XSS</a> using <a href="http://nl.php.net/filter" rel="nofollow">filter</a></li> <li>Protect against <a href="http://en.wikipedia.org/wiki/SQL_injection" rel="nofollow">SQL-injection</a> using <a href="http://net.tutsplus.com/tutorials/php/why-you-should-be-using-phps-pdo-for-database-access/" rel="nofollow">PDO</a>(prepared statements).</li> <li>Protect against <a href="http://shiflett.org/articles/cross-site-request-forgeries" rel="nofollow">CSRF</a></li> </ol>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. 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