Sp1d3r Posted October 5, 2008 Posted October 5, 2008 I'm trying to learn and understand mccode as much as i can and this maybe a noob question with the answer being over looked, but how does the script now how to create all the different tables in the database? for example announcements, where does it say make that table? thanks for any light you can shine on this. Quote
Dylan Posted October 5, 2008 Posted October 5, 2008 Re: install.php umm well I don't know what your asking but the install.php executes the .sql file into the database "This file contains all your game SQL". Quote
mdshare Posted October 5, 2008 Posted October 5, 2008 Re: install.php Looks like you want a game without even knowing the basics of MySQL The minimum MySQL syntax to know: CREATE Command - is used to create a database/table. SELECT Command - is used to retrieve data from the database. DELETE Command - is used to delete data from the database. INSERT Command - is used to insert data into a database. UPDATE Command - is used to update the data in a table. DROP Command - is used to delete or drop the database/table. Syntax for Query Commands CREATE Command The Create command is used to create a table by specifying the tablename, fieldnames and constraints as shown below: Syntax: $createSQL=("CREATE TABLE tblName"); Example: $createSQL=("CREATE TABLE tblstudent(fldstudid int(10) NOTNULL AUTO_INCREMENT PRIMARY KEY,fldstudName VARCHAR(250) NOTNULL,fldstudentmark int(4) DEFAULT '0' "); SELECT Command The Select command is used to select the records from a table using its field names. To select all the fields in a table, '*' is used in the command. The result is assigned to a variable name as shown below: Syntax: $selectSQL=("SELECT field_names FROM tablename"); Example: $selectSQL=("SELECT * FROM tblstudent"); DELETE Command The Delete command is used to delete the records from a table using conditions as shown below: Syntax: $deleteSQL=("DELETE * FROM tablename WHERE condition"); Example: $deleteSQL=("DELETE * FROM tblstudent WHERE fldstudid=2"); INSERT Command The Insert command is used to insert records into a table. The values are assigned to the field names as shown below: Syntax: $insertSQL=("INSERT INTO tblname(fieldname1,fieldname2..) VALUES(value1,value2,...) "); Example: $insertSQL=("INSERT INTO Tblstudent(fldstudName,fldstudmark)VALUES(Baskar,75) "); UPDATE Command The Update command is used to update the field values using conditions. This is done using 'SET' and the fieldnames to assign new values to them. Syntax: $updateSQL=("UPDATE Tblname SET (fieldname1=value1,fieldname2=value2,...) WHERE fldstudid=IdNumber"); Example: $updateSQL=("UPDATE Tblstudent SET (fldstudName=siva,fldstudmark=100) WHERE fldstudid=2"); DROP Command The Drop command is used to delete all the records in a table using the table name as shown below: Syntax: $dropSQL=("DROP tblName"); Example: $dropSQL=("DROP tblstudent"); Quote
Sp1d3r Posted October 5, 2008 Author Posted October 5, 2008 Re: install.php No im not asking for the code, i own v2. I was just looking at the install.php and noticed where it adds the information for the users, like hp and energy.. I was just curious how does it know to make all the other tables? is there another php file that it looks at to know if it should make a table named ice cream or items... I mean it just doesnt pull that information out of thin air, something has to say when installing this game here are the tables that are needed right? thanks! Quote
Floydian Posted October 5, 2008 Posted October 5, 2008 Re: install.php umm well I don't know what your asking but the install.php executes the .sql file into the database "This file contains all your game SQL". That is essentially your answer. I couldn't show you any code from mc version 2 since I don't own a copy and licensing makes it impossible to get/distribute the code legally without paying for it ;) I can however show you how my engine, Horizons Game Engine, accomplishes the same thing: $command = 'mysql -u ' . DB_USER . ' -p' . escapeshellarg(DB_PASS) . ' '. DB_SCHEMA . ' < ' . BASE_URI . 'horizon.sql'; $output = shell_exec($command); What does that do? First I define a string that will be executed in a shell (command prompt, i.e., DOS prompt). mysql -u username -puserpass databasename < path/to/file/horizons.sql The second line there executes that command. And that's all there is to it. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.