Mysidia Adoptables Support Forum  

Home Community Mys-Script Creative Off-Topic
Go Back   Mysidia Adoptables Support Forum > Mysidia Adoptables > Questions and Supports

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 07-03-2013, 08:16 AM
Infernette Infernette is offline
CODE CODE CODE CODE CODE
 
Join Date: Jan 2013
Location: Where I live? I live home.
Posts: 164
Gender: Female
Credits: 23,872
Infernette is on a distinguished road
Default Database functions?

I see that there are normal ways of going about deleting certain rows in the database (I.E. All adopts with the owner "None") And there are ways to count rows (I.E. Counting all adopts that you own that are under level 5 so you can limit eggs when adopting) but they seem to be hard to incorporate with the normal way that the database functions are handled. Is there any way to go about this in the same way but with the whole "$mysidia->db-> stuff?



(Currently working on a random adopt maker, it's getting fun (even though a simple show description of the adopt it's showing is getting annoying XD))
__________________
No, I have no idea what I'm doing. But it works. Barely.
Reply With Quote
  #2  
Old 07-03-2013, 02:16 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 334,462
Hall of Famer is on a distinguished road
Default

Well its easy to delete certain rows, the below code gets rid of every entry that has owner as 'none' in table prefix_owned_adoptables.

PHP Code:
$mysidia->db->delete("owned_adoptables""owner = 'none'"); 
Its also super easy to get the number of rows, simply do:

PHP Code:
$count $mysidia->db->select("tablename", array(), "conditions")->rowCount(); 
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #3  
Old 07-04-2013, 02:41 PM
Infernette Infernette is offline
CODE CODE CODE CODE CODE
 
Join Date: Jan 2013
Location: Where I live? I live home.
Posts: 164
Gender: Female
Credits: 23,872
Infernette is on a distinguished road
Default

Oh that is actually really awesome! I wasn't expecting it to be so straightforward now XD

AWESOME I got it to work :D
__________________
No, I have no idea what I'm doing. But it works. Barely.

Last edited by Infernette; 07-04-2013 at 11:17 PM.
Reply With Quote
  #4  
Old 07-05-2013, 08:18 AM
Infernette Infernette is offline
CODE CODE CODE CODE CODE
 
Join Date: Jan 2013
Location: Where I live? I live home.
Posts: 164
Gender: Female
Credits: 23,872
Infernette is on a distinguished road
Default

Okay I got everything else to work but now the page isn't recognizing the adopt like the other pages I made. This is going to be hard >.<

Here's all the code in case it matters (duplicated/modified the daycare page)
  Spoiler: code 
Code:
<?php

class CrecheController extends AppController{

    const PARAM = "aid";
    const PARAM2 = "confirm";
    private $view;
	private $subController;
	private $adopt;
	private $image;

    public function __construct(){
        parent::__construct();
		$mysidia = Registry::get("mysidia");
		if($mysidia->input->action() == "click" or $mysidia->input->action() == "siggy") $this->adopt = new OwnedAdoptable($mysidia->input->get("aid"));
		if($mysidia->user instanceof Member){
		    $status = $mysidia->user->getstatus();   
			if($status->canlevel == "no") throw new InvalidActionException($mysidia->lang->banned);
		}	
    }
	
	public function view(){
		$mysidia = Registry::get("mysidia");
		$document = $mysidia->frame->getDocument();
        $document->setTitle($mysidia->lang->daycare_title);
        $document->addLangvar($mysidia->lang->daycare, TRUE);

		try{
		    $daycare = new Daycare;
			$adopts = $daycare->getForadopts();
		}
		catch(DaycareException $dae){
		    $message = $dae->getmessage();
		    $document->addLangvar($mysidia->lang->{$message});
			return;
		}
		
		$daycareTable = new Table("daycare", "", FALSE);
		$daycareTable->setBordered(FALSE);
		$total = $daycare->getTotalAdopts();
        $index = 0;

		for($row = 0; $row < $daycare->getTotalRows(); $row++){
	        $daycareRow = new TRow("row{$row}");
            for($column = 0; $column < $daycare->getTotalColumns(); $column++){
			    $adopt = new OwnedAdoptable($adopts[$index]);
				$image = new Link("creche/adopt/{$adopt->getAdoptID()}", $adopt->getImage("gui"), TRUE);
				      $level = $mysidia->db->select("levels", array("primaryimage", "alternateimage","description"), "adoptiename='{$this->adopt->lvltype}' AND thisislevel='{$adopt->currentlevel}'")->fetchObject(); 

				$stats = new Comment("{$level->description}");
				$daycareCell = new TCell(new ArrayObject(array($image, $stats)), "cell{$index}");
                $daycareCell->setAlign(new Align("center", "center"));
				$daycareRow->add($daycareCell);
				$index++;
				if($index == $total) break;
            }
            $daycareTable->add($daycareRow);			
		}
		
        $document->add($daycareTable);
		if($pagination = $daycare->getPagination()) $document->addLangvar($pagination->showPage());
	}
	public function creATEaBunchOFeggsens(){
		$mysidia = Registry::get("mysidia");
		$document = $mysidia->frame->getDocument();
		
$mysidia->db->delete("owned_adoptables", "owner = 'none'");  
			$document->setTitle("Delete Successful!");
			$document->addLangvar($message);
			$document->add(new Link("myadopts/manage/nothin", "Deleted"));
			return;
}
	public function alladoptsdeletedgoodbye3231281ye721(){
		$mysidia = Registry::get("mysidia");
		$document = $mysidia->frame->getDocument();
		
$mysidia->db->delete("owned_adoptables", "owner = 'none'");  
			$document->setTitle("Delete Successful!");
			$document->addLangvar($message);
			$document->add(new Link("myadopts/manage/nothin", "Deleted"));
			return;
}
	public function adopt(){
		$mysidia = Registry::get("mysidia");
		$document = $mysidia->frame->getDocument();
if($this->adopt->owner= "None"){
$n = count($mysidia->db->select("owned_adoptables", array("aid"), " owner='{$mysdia->user->username}' AND currentlevel < 6")->fetchAll()); 
				 $row = $mysidia->db->select("users", array(), constant("PREFIX")."users.username='{$mysidia->user->username}' ")->fetchObject();
				 			$document->setTitle("Adoption Successful!");
		 $slotsleft = $row->slots - $n;
		 if($slotsleft >= 1){
            $mysidia->db->update("owned_adoptables", array("owner" => $mysidia->user->username), "breedcode = '{$adopt->getAdoptID()}'");
			$document->setTitle("Adoption Successful!");
			$message = "<br>You have adopted this pet! You can now manage it in your ";
			$document->addLangvar($message);
			$document->add(new Link("myadopts/", "Holding Area."));
			}
elseif($slotsleft < 1){
			$document->setTitle("Error");
						$message = "<br>You have too many eggs to adopt this pet, you need to hatch one before getting another.";
			$document->addLangvar($message);
}
return;
}
else{
$document->setTitle("Cheating");
			$message = "<br>Not supported in the forest, please upgrade your account to BANNED.";
			$document->addLangvar($message);
}
}
}
?>
__________________
No, I have no idea what I'm doing. But it works. Barely.

Last edited by Infernette; 07-05-2013 at 09:26 AM.
Reply With Quote
  #5  
Old 07-06-2013, 11:56 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 334,462
Hall of Famer is on a distinguished road
Default

Well copying/pasting pages is kinda tricky for sure. First of all, the lang vars need to be modified properly. You need to create a lang file inside the folder /lang with the appropriate lang var defined in array format. On the other hand, keep an eye on the naming conventions/patterns for your class method names.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #6  
Old 07-07-2013, 06:33 PM
Infernette Infernette is offline
CODE CODE CODE CODE CODE
 
Join Date: Jan 2013
Location: Where I live? I live home.
Posts: 164
Gender: Female
Credits: 23,872
Infernette is on a distinguished road
Default

yeah I'm way past that step, I just can't seem to get the adopt function to work with $adopt->*whatever* which is kinda odd since it has worked with any of the other pages I've made.

I might try to get the adopt ID from the URL and work it to use that to get the info, but it seems to be a complicated process and none of the tutorials help with using slashes instead of the old mys way >.<


I guess while I mull over how to do that I should work on making companions and art for them, so no more questions for now XD

Thanks :)

EDIT: Holy carp I just realized I can just move the adopt function to a different page and it'll still work. HERPDERP. >.<
__________________
No, I have no idea what I'm doing. But it works. Barely.

Last edited by Infernette; 07-07-2013 at 10:50 PM.
Reply With Quote
  #7  
Old 07-08-2013, 12:13 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 334,462
Hall of Famer is on a distinguished road
Default

lol... So is it safe to assuming that you've gotten it to work? Anything else still going wrong?
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
  #8  
Old 07-08-2013, 02:33 PM
Infernette Infernette is offline
CODE CODE CODE CODE CODE
 
Join Date: Jan 2013
Location: Where I live? I live home.
Posts: 164
Gender: Female
Credits: 23,872
Infernette is on a distinguished road
Default

Arguing with it to make multiple types (Rand y u no listen ) but other than that I think I have everything to get this site done in 16 days XD

Except cron jobs. But looking into alternate ways is easy...
__________________
No, I have no idea what I'm doing. But it works. Barely.

Last edited by Infernette; 07-08-2013 at 05:47 PM.
Reply With Quote
  #9  
Old 07-10-2013, 12:13 PM
Hall of Famer's Avatar
Hall of Famer Hall of Famer is offline
Administrator, Lead Coder
 
Join Date: Dec 2008
Location: South Brunswick
Posts: 4,448
Gender: Male
Credits: 334,462
Hall of Famer is on a distinguished road
Default

I see, looks like you are making some progress. Cron jobs can be a pain to work with, you can actually simulate cron jobs with PHP simply by having scheduled tasks run whenever a user visits the page, a member, guest or even bot wont really matter here. Make sure to check whether the cron jobs should run by comparing datetime string/integer, otherwise you may end up with multiple cron jobs executing at times they really should not.
__________________


Mysidia Adoptables, a free and ever-improving script for aspiring adoptables/pets site.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding Item Functions - help! Missy Master Questions and Supports 4 06-30-2014 08:50 PM
Problem whit functions.php edition Jocla Questions and Supports 8 03-03-2013 12:28 PM
Something wrong in my functions.php Abronsyth Questions and Supports 2 04-29-2012 03:01 PM
Suggestions for default Item functions Hall of Famer Suggestions and Feature Requests 36 01-14-2012 09:21 AM
image under functions.php PokePets Questions and Supports 4 08-09-2010 07:46 AM


All times are GMT -5. The time now is 02:38 PM.

Currently Active Users: 9894 (0 members and 9894 guests)
Threads: 4,080, Posts: 32,024, Members: 2,016
Welcome to our newest members, jolob.
BETA





What's New?

What's Hot?

What's Popular?


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
vBCommerce I v2.0.0 Gold ©2010, PixelFX Studios
vBCredits I v2.0.0 Gold ©2010, PixelFX Studios
Emoticons by darkmoon3636