Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Include necessary files.
- require_once("./App/Class.file.php");
- require_once("./App/Class.config.php");
- require_once("./App/Class.lang.php");
- require_once("./App/Class.database.php");
- // Open a file, called Text.txt, and allow reading and writing (TRUE, TRUE).
- // You can also allow the appending and file creating by adding the
- // appropriate "TRUE/FALSE, TRUE/FALSE" after the read/write boolean options.
- $file = File::Open("./Test.txt", TRUE, TRUE);
- // If there is something wrong with the file, it will echo the error here and continue.
- if($file->classType == "Message")
- {
- if($file->type == "Error")
- {
- echo $file->message;
- }
- }
- else
- {
- $file->Write("Hello, World!");
- // Fetch contents of the file.
- // the reason it's echoign the "->message" is because it sends all data/error/success messgaes
- // to a log so it can be logged when desired. So the GetContents() function returns a Message
- // with type "Data" and the message as the file content. This way, we can see in the log exactly
- // what is happening and where.
- echo $file->GetContents()->message;
- // Close the file.
- $file->Close();
- }
- // This is how you fetch an option from the config.
- echo Config::Fetch("SiteName")->message;
- // This is how you get a line from a language file, and then you
- // replace the marker [file] with "./Example.txt".
- echo Lang::Get("file.FileNoExist", array("file" => "./Example.txt"))->message;
- // Open a DB connection
- $db = Database::Connect("localhost", "root", "password");
- // make a query and echo the output with my query constructor.
- $query1 = $db->NewQuery()
- ->Select(array("id", "username"))
- ->From(array("example_table"))
- ->Where(array("first_name" => "Caelan", "last_name" => "Stewart"));
- // Execute the query above.
- $output = $db->ExecQuery($query1);
- print_r($db->FetchArray($output->message));
- // Insertion constructor, accepts strings, numbers, boolean.
- $query2 = $db->NewQuery()
- ->Insert("SomeTable", array(
- "Column1" => "Column1 Value",
- "Column2" => 1234,
- "Column3" => FALSE
- );
- $db->ExecQuery($query2);
- // Custom SQL query
- $query3 = $db->NewQuery()
- ->Custom("SELECT * FROM `users` WHERE `id` = 56");
- $db->ExecQuery($query3);
- // There you have it, that's my system so far...
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement