[pLog-svn] r3249 - plog/trunk/tools
oscar at devel.lifetype.net
oscar at devel.lifetype.net
Fri Apr 14 12:43:51 GMT 2006
Author: oscar
Date: 2006-04-14 12:41:28 +0000 (Fri, 14 Apr 2006)
New Revision: 3249
Modified:
plog/trunk/tools/generateData.php
Log:
it is now possible to run this script from the command line, so that we can add a lot more data in one go (because php scripts run from the command line don't have time limits) Just move it to your root LT folder and off you go.
Modified: plog/trunk/tools/generateData.php
===================================================================
--- plog/trunk/tools/generateData.php 2006-04-14 12:18:50 UTC (rev 3248)
+++ plog/trunk/tools/generateData.php 2006-04-14 12:41:28 UTC (rev 3249)
@@ -16,6 +16,12 @@
include_once( PLOG_CLASS_PATH."class/dao/articlecomments.class.php" );
include_once( PLOG_CLASS_PATH."class/dao/usercomment.class.php" );
+// check whether we're being run from the command line
+$commandLine = is_array( $argv );
+if( $commandLine )
+ $nl = "\n";
+else
+ $nl = "<br/>";
// please tweak these parameters to suit your needs
$params = Array ( "numUsers" => 50,
@@ -92,7 +98,7 @@
// generate as many users as required and put them in the pool
$i = 0;
$users = new Users();
-print("Adding ".$params["numUsers"]." users...<br/>");
+print("Adding ".$params["numUsers"]." users...{$nl}");
while( $i < $params["numUsers"] ) {
$text = generateRandomWord( rand( 3, 12), false, false );
$user = new UserInfo( $text, // username
@@ -104,9 +110,12 @@
// add the user to the db
if( $users->addUser( $user )) {
$userPool[$i+1] = $user;
+ print("User $i added to the db...{$nl}");
+ ob_flush();
+ flush();
}
else {
- print("There was an error adding user $i - $text<br/>");
+ die("There was an error adding user $i - $text{$nl}");
}
$i++;
@@ -117,7 +126,7 @@
$blogs = new Blogs();
$numBlogs = $params["numBlogs"];
$usersPerBlog = $params["numUsersPerBlog"];
-print("Adding ".$numBlogs." blogs with $usersPerBlog users<br/>");
+print("Adding ".$numBlogs." blogs with $usersPerBlog users{$nl}");
while( $i < $numBlogs ) {
$randUserId = rand(1,$params["numUsers"]);
$blog = new BlogInfo( generateRandomWords( rand(1, 10 )), // blog title
@@ -194,9 +203,12 @@
$k++;
}
+ print("Blog $i added {$nl}");
+ ob_flush();
+ flush();
}
else {
- print("There was an error adding blog $i<br/>");
+ die("There was an error adding blog $i{$nl}");
}
$i++;
@@ -204,5 +216,5 @@
// generate the categories and put them in the category pool
-print("Complete!<br/>");
+print("Complete!{$nl}");
?>
More information about the pLog-svn
mailing list