Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




PEAR DB_DataObject Auto-generator Multiple Databases


I'm using the DB_DataObject script createTables.php to auto-generate
the necessary database schema on two databases. Using the .ini
approach (not the in-line PHP approach) to configure DB_DataObject in
my script. Everything is by the book, but I'm having a big problem:

Here's my main.ini file:
[DB_DataObject]

database_one = mysql://user:password@localhost/one
database_two = mysql://user:password@localhost/one
schema_location = /home/user/classes/dataobjects
class_location = /home/user/classes/dataobjects
require_prefix = /home/user/classes/dataobjects
class_prefix = DataObject_

And here's my database connect file:
<?php
// separate classes for each database
class DataObject_one extends DB_DataObject { var $_database = 'one' }
class DataObject_two extends DB_DataObject { var $_database = 'two' }
$config = parse_ini_file('/home/user/classes/main.ini', TRUE);
foreach($config as $class=>$value) {
$options = &PEAR::getStaticProperty($class,'options');
$options = $value;
}
$DB = DataObject_one::factory("tableName");
// etc...
?>

The problem is that the auto-generator createTables.php copies
everything into one directory, regardless of the number of databases
you enter in your .ini file, which means, as is the case for me in this
example, if you have two tables with the same name on different
databases, it'll keep overwriting the same file, and the resulting
class is the LAST one you enter in your .ini file.

So my question is this: is there a way to specify different
subdirectories for different databases in your initial configuration
file? If not, is there no other solution than giving every table a
unique name across an entire MySQL server if you don't want to do any
coding?




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
PEAR Db_DataObject: Joining And Grouping
I'm excited about using DB_DataObjects classes to interact with my database. Trouble is that there seem to be no resources/tutorials that deal with complex joins. The PEAR manual suggests you are better off feeding the raw query into $object->query(); Once you do that, however, how do you extract the result and render say:

I have tables for user, address, city, and county. I want to take my query and:

Auto Generator Codes.
I know this is very easy.

what i want is a six codes generator.

Let say i have a button when i press this button it will generate six digit codes.
for example i have this code 543545.

now i wanted also when i use this code it will tell me it's the valid codes.

maybe you have the idea, just want to know the functions that i should use for this.

Trouble With Multiple Mysql Databases
I'm having trouble accessing multiple databases using a single user.

Basically, I have 2 databases, db1 and db2 and 2 users, user1 and user2.
Originally these were setup so that user1 would only access db1 and user2
would only access db2. However, now I want user1 to access both db1 & db2.

I've used cPanel to declare user1 as a user of db2. However, whenever I try
to access db2 from user1, I get permission problems.

I've tried various combinations of mysql_db_select(), mysql_query("USE
db2Name", $db1link) or just referencing the appropriate table as
'db2Name.tableName' in my SELECT querys but everytime I get a permission
denied response.

Any ideas?. It looks like a cPanel problem to me as it appears that user1 is
simply not being granted access to db2 despite telling cPanel to do so.

Auto Populating Multiple Drop Downs.
im trying to create two dropdowns, i need the first one to be the category and the second one to be the subcategory.  The category drop down autopopulates with the correct info from the database. and uses the table "category", the value of each drop down is represented by the "cat" field in the table (cat is basically and integer id number) and "Category" is used as what the user actually sees in the drop down (category is the actual word of the category).

Once the category is selected i would like to have the sub category auto populate with everything that has the same values as the selected category (cat)

Here is a break down of how the tables work.

Table 1 Name: "category"
Fields for Table 1:  "cat" (the id number), "category" ( the actual name of the category)

Table 2 Name: "subcategory"
Fields for Table 2: "cat" (corresponds with the cat id from table 1 to pull the correct data), "subc" (the basic id of the subcategory), "subcat" the actual name of the subcategory.

so the way i see it, have a normal drop down populated by a php query. then on change, populate subcategory drop down where cat = cat and display sub category.

Auto-populating Multiple Boxes... Php And Pg_fetch_array Problem?
There is a nice tool using jquery/php to populate multiple select boxes out
there, it must be a very stupid question but I?m trying to apply this tool to get data from postgreSQL, but I always get an empty [] value. It means that the...

DB_DataObject Get ID
how to get the ID of the object after calling $mydbdataobject->insert()?

Help Needed With DB_DataObject
I have just adopted a PHP project and need some help understanding
DB_DataObject. I've looked around on the web and can't find a simple
explanation.

Basically, my MySQL database has no tables. I have a createTable.php
script which I believe is a standard script, it runs but tell me "NO
TABLES". There is a function in the script called _createTableList()
which is looking for tables not finding any (I don't really
understand why there should be pre-existing tables when the script is
supposed to be creating them...)

I have .ini files which seem to describe the schema, and classes which
correspond to the entries in the .ini file - but no SQL, and I do not
understand how to get the schema into the database. I believe the
environment is set up correctly for the script to find the .ini files.

I hope that was clear, and I hope somebody here can advise me - I'm sure
it's simple enough for somebody who knows what they're doing with
DB_DataObject!

Using PHP5 btw, if that matters.

PEAR Newbie Trying To User PEAR DB And Falling At The First Hurdle
I've just installed PEAR on my local machine and all is well, updated
the include_path to point to my PEAR dir. So, when I just try to make
a simple connection like so the script just seems to stop but no error
messsages. I do get error messages normally (ie. when I can a method
from an object that doesnt actually exist) as I have set...

Name Generator
I’m going to be creating a username generator that gives you a few usernames you could use, based on the one you asked to have but was taken.

For example, when you signup for a hotmail account and the e-mail address you specified is already taken, it gives you a few choices to pick from based on DOB, age, etc., or create your own custom one again.

The thing I’m going to be making is very similar. Instead stead of generating some names based on your DOB, age, etc. it will just give some names with numbers added on, or whatever the guy I’m making it for wants it to operate. Like I enter in Epsilon and it is taken, it then gives me something like Epsilon2002 (Based on the current year), Epsilon_, Epsilon- and so on.

Password Generator ?
I want the password to generate a 8 character long and the password is A-Z, a-z, 0-9.

Looking For A PHP PIN Number Generator
I am looking for a script that generates PIN Numbers.

Is there one available somewhere out there? I don't mind algorithms if
they will be easy to implement in PHP.

Site Generator
Has anyone got any scripts that will, after a person registers, it will automatically create a directory for them?? Example:

User Registers -> Confiration Page -> User may now go to
http://mydomain.com/registeredusername with a default index.hml file

Also a File Manager. Does anyone know how to do this or where i can find such a script?

Code Generator
Does anyone knows a code generator for Php ?
Actions to do: specifiy a mysql table and their fields, and build a default
webpage which allows to add,update,delete,search, browse, print the table
data.

Site Map Generator
i was just wondering would it be possible to create a site map, where by you enter a URL and then it searches through the site and outputs this on a page. I know I've used a package which does this, but interested to see if it can be done using PHP?

Random Generator
This might seem a stupid question but here goes -

I wrote a key generator for one of my programs in Visual Basic, so I recieve
sales notification via email and then use my program to generate the key and
send it via Email.

Well after finding out about PHP, and that my host does PHP, I thought it would
be quicker and more reliable to generate the keys on the server and send them
out again either vai email or from the sales site.

So I wrote the generator in PHP and surprisingly it works, or rather it works
in a half assed fashion, I can generate keys, but they are not the same as the
ones generated by my VB program.

And here is my problem, I suspect its becuase I'm using a randomised Seed, and
I'm thinking that VB and PHP Randomisers are not compatable.

Am I right in my thoughts and if so, is there a way around it?
Is the only answer not to use a randomiser? or how do people generate keys from
the server when using other languages ie C++ etc?

Thumbnail Generator
Does anyone have a demo to look at for a very simple thumbnail generator for a jpg image? If a user uploads a jpg, and then a thumbnail is made of it.

Quiz Generator...
I have been doing through the web to search for a test/exam quiz generator that generate quiz, test and provide statistics. Most of them are commerical. Are there open source program for it in php?

Standalone Sig Generator
I currently have my sig generator running,  the problme Im facing is that it outputs like this http://mysite.com/image.php?sigimage.png

I need to have it out put like this -> http://mysite.com/image.png?sigimage.png or something like it because a lot of sites do not allow image.php. Code:

PHP Screenshot Generator
Does anyone know of any real-time screenshot generator? Where you can give the PHP file a URL and it will convert that URL page into a JPEG image with GD?

I have had a look around and only found a few but none seemed to do this job.
Anyone?

Table Generator
I have this way of getting a webpage to include a table from a comma
separated file. Works well for purpose I have used up to now but wish to
extend it to generate a table with a top row of cells of type th.
So two questions about this:

1. What exactly should the code be to enable this and
2. How should the csv file be formatted (if different from normal comma...

Password Generator- Unique?
I have a script that is supposed to generate unique passwords. Trouble is its producing passwords that already exist in the 'personaldetails' table. i don't think I'm the lucky type that wins the lottery everyday so it its not by chance - there is an error somewhere. (the userid is primary key and is autoincrement, I know thats not a standard way of doing it but that isn't causing this error)
The script is:

if ("SUBMIT"==$generate){
$String = "This is the text which will be encrypted so that we may create random and secure passwords!";
$Length = 8; // Change this value to indicate how long your passwords should be. 32 character limit.
$String = md5($String);
$StringLength = strlen($String);
srand ((double) microtime() * 1000000);
$Begin = rand(0,($StringLength-$Length-1)); // Pick an arbitrary starting point.
$password = substr($String, $Begin, $Length);
print ("Your recommended password is:<P><BIG>$password</BIG>
");

// Add the password to the database.

$sql = "INSERT INTO personaldetails SET " .
"firstname='$firstname', " .
"surname='$surname'," .
"password='$password'," .
"teacherstatus='$teacherstatus'";
if (mysql_query($sql)) {
echo("<P>Your password has been added to the database.</P>");
} else {
echo("<P>Error adding password to database: " .
mysql_error() . "</P>");
}
$Query5="SELECT userid FROM personaldetails WHERE password='$password'";
$result5=mysql_query($Query5) or die ("Can not execute query:" . mysql_error());
print("Your userid is " . mysql_result($result5,0) . ". This has also been added to the database. ");
}

I don't understand why its not generating unique passwords. As, a consequence I'm bringing back the userid for the password that was already in the table, I end up with 2 people sharing the same password and and the generator reports they have the same userid ( when I look in the table the newest row has been added and has a userid which is different to the userid of the other person in the table who has the first copy of the password. My query to bring back the userid is bringing back the userid of the first row it comes to that has the 'unique' password entry, unfortunately the password is not unique and so I get the wrong persons userid? - can you spot what is wrong with the generator?

Random Number Generator
<?php
function get_random_number_between($start, $end) {
srand((float)microtime()*1000000);
$random_number=rand($start,$end);
return $random_number;
};
echo get_random_number_between(2, 4);
?>

Could anyone suggest how to modify this code to output a float between 2 and 4 with 2 decimal places?

Password Generator- Unique?
I have a script that is supposed to generate unique passwords. Trouble is its producing passwords that already exist in the 'personaldetails' table. i don't think I'm the lucky type that wins the lottery everyday so it its not by chance - there is an error somewhere. (the userid is primary key and is autoincrement, I know thats not a standard way of doing it but that isn't causing this error)

The script is:

if ("SUBMIT"==$generate){
$String = "This is the text which will be encrypted so that we may create random and secure passwords!";
$Length = 8; // Change this value to indicate how long your passwords should be. 32 character limit.
$String = md5($String);
$StringLength = strlen($String);
srand ((double) microtime() * 1000000);
$Begin = rand(0,($StringLength-$Length-1)); // Pick an arbitrary starting point.
$password = substr($String, $Begin, $Length);
print ("Your recommended password isP><BIG>$password</BIG>
");

// Add the password to the database.

$sql = "INSERT INTO personaldetails SET " .
"firstname='$firstname', " .
"surname='$surname'," .
"password='$password'," .
"teacherstatus='$teacherstatus'";
if (mysql_query($sql)) {
echo("<P>Your password has been added to the database.</P>");
} else {
echo("<P>Error adding password to database: " .
mysql_error() . "</P>");
}
$Query5="SELECT userid FROM personaldetails WHERE password='$password'";
$result5=mysql_query($Query5) or die ("Can not execute query:" . mysql_error());
print("Your userid is " . mysql_result($result5,0) . ". This has also been added to the database. ");
}

I don't understand why its not generating unique passwords. As, a consequence I'm bringing back the userid for the password that was already in the table, I end up with 2 people sharing the same password and and the generator reports they have the same userid ( when I look in the table the newest row has been added and has a userid which is different to the userid of the other person in the table who has the first copy of the password. My query to bring back the userid is bringing back the userid of the first row it comes to that has the 'unique' password entry, unfortunately the password is not unique and so I get the wrong persons userid? - can you spot what is wrong with the generator?

Form Generator Or Class / OSX
i am sure we all know this Problem, u build a website and want to implement a CMS, so that the content can be updated easily. So u spend half a day building Form Sets for Update insert delete etc..

Does anyone here know of a good form generator that will build this forms automaticly? Best would be a Class or something but a desktop version that runs on OSX would be great too.

PHP File Map Generator/editor
Is there some software that can map the file tree (mainly the file includes within the PHP scripts) and create a tree to show where these files are included, and from which files. Rather like UML for c and c++ kind of function?

Database Or File For Name Generator ?
I am making a random name generator, it will pick two or three words
from a list and turn them into a name. It seems a database needs to
work with name/value pairs, so am I right in thinking for a simple
list, seperated by line breaks, a file is the most sensible choice ?
If so, what happens if someone else tries to write to the file whilst
I am working with it ?

Random Signature Generator
I'm trying to find a script for use on vB that will randomly generate a banner image (from a few images that I select in advance) when it loads in my signature. I've seen them at work, but can't seem to find them on, say, yahoo, or google.

Class Or Function For A Key Generator?
I need to be able to produce a string consisting of uppercase letters and numbers. I would also like it to produce e.g. a string of 6 characters all the time. A given number must allways result in same string such as "AE4YX8". Would also be nice if I could go from the string to the original number as well. Anyone with links to sites with example on how to do this?

Wanted: PHP Site Map Generator!
Having spent my free time over the last few months converting several
hundred pages of mainly static (s)html into eight pages of data driven php
loveliness and a whopping MySQL database I'm faced with a bit of a dilemma.

Will search engines be able to crawl all the index.php?query paths so
people can find stuff? I'm currently at the top of the heap on Google as my
site has been around for years and is pretty niche and I don't want to lose
that advantage.

Which leads to the main part of the question; is there a 'site map'
generator which will vreate a single crawlable HTM page with all my
possible pages on iot which I can then link to from my home page which will
enable the search spiders to do their thing?

Or am I left with the unenviable task of having to put response/redirects
on all the old pages pointing to the equivalent dynamic pages?



Random Pixel Generator
Im trying to create a program that generates random pixels from a set picture.. i know how to write a random number generator its just figuring out how to take that one step further and getting it to grab pixels from a picture and show them one by one when somebody clicks generate button. there needs to be 1,000,000 pixels in total. Raar my head hurts trying to think of a way to do it!

Secret Code Generator
The idea is that I can make a password and then encrypt it to make it safe when sending instant messages and emails to colleagues containing sensitive information.

The only way I could get this to work was by entering 1 letter per box. I want to be able to type a series of letter or words into one txt area and it be converted as usual.

Random Password Generator
how can I make a password generator using php and javacript so that whenever a button is clicked it generates a random password in a text box.

I've already done the password generator code. When I click on the button it generates a password but if I click it again it won't generate a different code.
So is there a way to have it generate a different password each time? Right now when I click on the button it will call the javascript function to change the text in the input box to  echo rand_pass(); like so

<input id="password" name="password" type="text" size="71" maxlength="128" style="margin-top:2px;" tabindex="26"/>
<input name="rand_pass" id="rand_pass" type="button" value="generate" onClick="generate( 'password', '<?php echo rand_pass(); ?>'  );" class="Buttons">

Sitemap Generator Script?
Does anyone know where I ca find a sitemap generator script?

Php, Databases, And Ssl
I am having issues with my implementing an ssl page to secure my site. My database access is password protected, but the issue is the actual transmission of the data from the login.php page to the database. A user was concerned about the security of this aspect, which is understandable.

What I want to do is find a way to have the query of the database take place behind a ssl layer, and once that is accomplished, leave that area. Quite simply, after login, all I do is access their name to greet them, and use their username as a session variable. I use Yahoo web hosting, and they have a ssl folder to use to get security. I tinkered with things, but couldn't figure out what links needed to be changed, nor how to properly direct the changes.

I was able to get it to work somewhat, but once I tried to login, I kept getting in a loop that reloaded the login page.

I hope this is enough information, although I have a premonition that it is difficult to answer this query without access to the code.

Two Databases
My query takes data from two seperate databases on the same MySQL server. The only problem is, each database has it's a username prefix. For example:

"user1_artists"
"user2_store"

This is because each database is on a seperate domain account (they both use the same MySQL username and password though). The code below works on my computer at home, but when I run it on the server it doesn't work. The reason why it works on my home computer is because the databases don't have user prefixes like my server does. Any ideas? PHP Code:

CVS For Databases?
I have developing a PHP/MySql web application with a team. We
are all located in different locations, so we cannot have anything
running on one local server.

We have a CVS setup on a virtual host for the php files, and that has
been working out great. Everyone has a local copy of the site, that
they can work on without being connected to the net and when they are
done working on something, they commit it to the cvs and then everyone
can get it from there.

The problem we have been having is keeping all of our local mysql
databases in sync. We each have a local php/mysql setup running (with
something like wamp). And once in a while while coding, we update the
local database...and after a week or two, we all end up with different
databases.

Is there some way that we can keep our database in sync (other than
hosting the database on the virtual host, because we want to be able to
work on this site when not on the internet (like in an airplane))? Is
there some way to "CVS" a database?

BTW, We have tried using phpmyadmin to dump the entire database to a
sql file and sending that to everyone, but it is a real pain updating
databases in that way because when you try to import that sql file back
on another database, phpmyadmin will timeout, so we have to break down
the file into smaller files etc.

If someone could point me to a good free/open source solution to this
problem, I would be grateful. If you need me to clarify the problem
further

Flat File Code Generator
I want to know how I can add breaks between table elements (html code) when it's generated from a flat file (input forms) ? Right now the code appears in one continous string, and I'd like it to be neat and tidy (breaking in the code after </td></tr> and </table>) Is this possible? Here's teh code, to show you what I mean :

http://stage.jpauldesign.com/mctl/h.../viewevents.php

Rapidshare Premium Link Generator :
I got a script from one of my friend.It is used for generating rapidshare premium links like : http://rapidfool.com/ But its not working !Code:

Six-random No Generator, But Not In Good Ordering
how to put a randomly generate in to an array, so that I can sort them with sort function?

result is:
B1 38 + 41 + 34 + 30 + 27 + 22
B2 34 + 22 + 10 + 35 + 18 + 11
B3 34 + 2 + 7 + 34 + 37 + 1
B4 30 + 34 + 7 + 2 + 27 + 25

//$holdno = array ($rno);
//sort ($holdno);
//echo sort($holdno);
//reset ($holdno);

I follow from php.net, they are wrong. I need something like:

$holdno(1)=no(random draw1)
$holdno(2)=no(random draw2)
$holdno[sixno] = $rno;
echo $holdno[sixno];

I tried this but I can't sort them.
....
....etc its very difficult, when a nos is drawn, it is not put back to pool, and continue to draw a nos. leave question 2 for the time being. PHP Code:

Php - Mysql Form Field Generator
does anyone know of a simple function/class that will take config
options: table name and the database connection stuff(or whatever)
It will then print out appropriate form fields to allow editing of a
row?

The reason being is that in the admin section of a website I am
building we are constantly adding columns to a table...It is used for
keeping config options of the site. We do not wanna update the form
each time we add a column.

Can My Server Take The Load Of This Thumbnail Generator?
My server: Shared VPS
Centos 4
Equal share CPU
1GB Burst RAM
256MB RAM

My question: I have a .php file generate thumbnails on the fly. I have a moderate amount of traffic. Sometimes the gallery(s) shown can list up to 20 or so images, with fairly large thumbnails. Am I causing uneccessary server load by not just making my own thumbnails and having all these galleries generated on the fly?

Sequential Alphanumeric String Generator
I was wondering how I would generate a set of Alphanumeric strings with PHP. So the script would run and output something like:

a
b
c
d
..
x
y
z
aa
ab
ac
ad
...and so on.

Alpha would be good, although Alphanumeric would be much better. Also the option to define how many characters long the string can be would be a plus.

Permissions Problem With Sitemap Generator
I have bought a standalone xml sitemap generator online.I am new to webhosting and a newbie in all these stuff.I ahve followed all the instructions by the software provider, but still cant get my sitemap ready.
The error showing is

"config file is not writable: /home/mydomain/public_html/generator/config.inc.php
Datastorage folder is not writable: /home/mydomain/public_html/generator/data/"

however i have changes the permission of these files in my server to 0666 and 0777 as instructed. But when I try to save my configuration it shows the above mentioned error.

Addslashes() In Databases
Is that true, that when i want to store data into a database it's better to use addslashes($var)

and when i want to retrive the data from the database it's better to stripslashes($var).

Huge Databases
Say I have a remote site, how would I go about "reuploading" a 2gb database that was crashed. I had to delete one as the records were skewed, and I have a backup on my computer. But doing like 15 million queries, that doesn't sounds like the best way to have this database back up and running.

Closing Databases
I am using mysql_connect($host,$user,$db_password); to open a mySQL database. Do I need to be closing the database manually after working with it on the page or does php automatically take care of this ?

Two Classes - Two Databases
I have two functions which make a new class and each a connection to a different database.
PHP Code:

PHP & Paradox Databases?
I've been experimenting with PHP & MySQL-databases for a while now, but now I'm trying to use existing Paradox databases. The problem is I don't know how to connect to it (I read something about ODBC but I don't really get it..)

Databases And Classes
I wrote this as a test to see how classes work with database connections. The first part of feedback (PART A) works, and it cycles through my list of users and displays them no problem, but it doesn't move onto the second loop. I expect it's something to do with the 'while' statement. Can anyone see what i'm doing wrong? PHP Code:


Copyright © 2005-08 www.BigResource.com, All rights reserved