Login   Register  
PHP Classes
elePHPant
Icontem

File: PhpUtilsTests.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Orazio Principe  >  PHP Utils  >  PhpUtilsTests.php  >  Download  
File: PhpUtilsTests.php
Role: Example script
Content type: text/plain
Description: Just two examples
Class: PHP Utils
Provide general purpose functionality
Author: By
Last change:
Date: 2 years ago
Size: 1,002 bytes
 

Contents

Class file image Download
<h1>Just 2 tests to uderstand how to use the cass PhpUtils</h1>
<?php
require_once("PhpUtils.php");

$link_id mysql_connect("localhost""remoteuser""remotepswd");
mysql_select_db("mysql");


echo 
"<fieldset>";
echo 
"<legend><b>PhpUtils::getResultCounter</b></legend>";
$code = <<<CODE
\$sql = "SELECT count(*) as total_rows from user";
echo PhpUtils::getResultCounter(mysql_query(\$sql));
CODE;
echo 
nl2br($code);

echo 
"</fieldset>";
echo 
"<hr />";


echo 
"<fieldset>";
echo 
"<legend><b>PhpUtils::getObjectsFromResults</b></legend>";
$code = <<<CODE
require_once("DbMySql_initializer.php");
class User extends DbMySql_initializer
{
    &nbsp;&nbsp;&nbsp; public \$Host;
    &nbsp;&nbsp;&nbsp; public \$User;    
};

\$sql = "SELECT * FROM user";
\$els = PhpUtils::getObjectsFromResults(mysql_query(\$sql), "User");
foreach(\$els as \$user)
{
    &nbsp;&nbsp;&nbsp; echo \$user->User;
    &nbsp;&nbsp;&nbsp; echo "&lt;br /&gt;";
}
CODE;
echo 
nl2br($code);
echo 
"</fieldset>";
echo 
"<hr />";



?>