Home Community Mys-Script Creative Off-Topic |
|
|
Thread Tools | Display Modes |
#1
|
||||
|
||||
Seeking basic run down of php and database
I'm trying to my hardest to change my way of coding to suit the site, but the one thing I can't seem to get a grasp of, is how all the database queries are handled.
Can someone please give me a basic run down, since we don't have any documentation(As far as I know). $mysidia->db->select("table", array(), "thing = '$thing'")->fetchColumn(); I can assume that this part "$mysidia->db->select" is used to select the database information and so on. Instead of like "mysqli_query()", which is what I'm use to. I don't understand why the array is there, and the "->fetchColumn()" part. I also don't understand why there is like "$result" variable after the MySql codes. So I just need a basic run down, a little bit of help to understand, then I can start coding and working on features. (I'm working on a few things. Like displaying a user's favourite pet in the sidebar) Please and thank yous D=!!! |
#2
|
||||
|
||||
Okay. So I think I've got it. After fiddling and being impatient for a reply.
But I would like a second pair of eyes to look at my code. (Instead of adding the php in the module area, I prefer to add it to the class_sidebar.php file. It's easier for coding and checking backwards and forwards. The main code: Code:
protected function setFavPetSB(){ $mysidia = Registry::get("mysidia"); $userfavpet = $mysidia->db->select("users_profile", array("favpet"), "username = '{$mysidia->user->username}'")->fetchColumn(); if ($this->userfavpet == "0"){ $this->FavPetSB = new Paragraph; $this->FavPetSB->add(new Comment("<b>No Favorite Pet Set</b>")); } else{ $this->FavPetSB = new Paragraph; $this->FavPetSB->add(new Comment("<b>Favorite Pet!</b>")); $this->FavPetSB->add(new Link("levelup/click/{$userfavpet}", new Image("levelup/siggy/{$userfavpet}"), TRUE)); } $this->setDivision($this->FavPetSB); } |
#3
|
||||
|
||||
If you like, I've been slowly working on this guide.
Or, in short, for just your question: Database SQL Statements You’ll need to have access to the registry first, in whatever function you're dealing with, of course. PHP Code:
Count how many rows match a specific query:Where Data Fetching an exact value in a specified column:Fetching Row Data as an Object Example:Creating a New Row of Data Example:Updating Data
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it. |
#4
|
||||
|
||||
As for your code above, because the Sidebar widget is partially controlled on the AdminCP you will also have to make changes there. AdminCP > Module > Create New Module:
You could also probably manually do this in the database (in the _modules table), but it's just not being done with code alone. (Note: the Module Order slot controls the order in which the modules in the sidebar will appear, lower numbers are higher.) I also notice your code above is only a setter but there is no getter. The money bar has a getter, so just add one similar above your code: PHP Code:
PHP Code:
Lastly, the code you had looked familiar, but it's something that's slightly broken in the code itself, currently. Inside class_userprofile.php I'd replace the getFavpet function: PHP Code:
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it. Last edited by Kyttias; 01-13-2015 at 10:12 AM. |
#5
|
||||
|
||||
Thank you so much for the basic run down and the guide.
As for the code, thank you for the edits :) I already have the getter, and the module set up. The code works, I'm just rusty and needed a second pair of eyes to make sure. I know that levelup/siggy/{$numberhere} isn't an image, yet it still works, oddly enough. But you're right, it should be changed. Thank you again for the help. I can finally start working on editing the current features and adding my own. (I plan to add my own item rarity system, but also add a rarity system for pets. Because I want them to be random in what they adopt. Since our site is focused on collecting) |
#6
|
||||
|
||||
Nice! I also added an item rarity to my site. It has little use right now, but combined with a shop loyalty system, I'll be withholding some items from shops until a user has 'levelled up' a shop, thus, rarer items will be in shops after a user has gained enough shop loyalty. I'll also be having item capsule ball machines and drop chances while exploring, these effected by arrays of different rarities of items. ^^
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it. |
#7
|
||||
|
||||
Yes, I saw that in your thread! I love that idea so much.
I also love the capsule ball machines. Gacha as they call it in Japan. I want to have items drop as well, but I want to make it so they have to claim it. So that people can't use refreshers or auto scripts and stuff. I also want to work on adding a stocking and restocking system for my stores. My site is all to do with collecting you see XD Collecting pets, and items, and all kinds of goodies. Because I love collecting when it comes to websites. |
#8
|
||||
|
||||
I'm trying to build a custom page, but it kinda breaks the theme. It makes the background on the default theme white, and in the bootstrap one, it changes the theme colours around (To colours that are in the theme, but different ones) and it makes the text bigger.
test.php Code:
<?php class TestController extends AppController{ public function index(){ $mysidia = Registry::get("mysidia"); } } ?> Code:
<?php class TestView extends View{ public function index(){ $mysidia = Registry::get("mysidia"); $document = $this->document; $document->setTitle("Test"); $document->add(new Comment("Test")); } } ?> Last edited by MikiHeart; 01-15-2015 at 07:56 AM. |
#9
|
||||
|
||||
Well, it definitely shouldn't be misspelled. The view should match the controller. Blank always gave me troubles, too... I ended up using the Donate page as my base - it also helped me understand how form data was being tossed from the view to control and back.
__________________
Please do not contact me directly outside of Mysidia.
I also cannot troubleshoot code more than two years old - I legit don't remember it. |
#10
|
||||
|
||||
It's weird, because the blank page actually works. It's weird.
I will try the donate page as a base. If it still doesn't work, I'll post a new topic and hopefully HoF can give some insight. |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Seeking Advanced PHP Coder (PAID) | SoubisSacrifice | Staff Central | 14 | 01-29-2015 10:42 AM |
Seeking a coder + artists~ | Pear | Staff Central | 14 | 07-06-2014 03:42 PM |
I need basic coding help | Moontides | Feedback and Suggestions | 23 | 05-28-2014 01:54 PM |
Seeking Mysidia coder | Solistia | Staff Central | 4 | 05-03-2011 04:19 AM |
My BASIC programs | SleepWalker | Other Chat | 0 | 04-05-2010 08:37 AM |
What's New? |
What's Hot? |
What's Popular? |