![]() |
Get rest of var name
I was wondering if you have a variable like
PHP Code:
PHP Code:
PHP Code:
PHP Code:
(hope this makes sense). |
there is
HTML Code:
getstringkeys("this.string_");HTML Code:
this.string_hi |
Well, what im trying to do is make a temp.var to get the end of a string.
so if the string is bids.sssssssssss.weapons.sword id want to be able to search through for all bids.sssssssssss then make a var that contains weapons.sword. I only want to do this, because there is another var weapons.sword.selleracct.bla bla that I need to pull only a few certain things from on a bid. |
hmm you answered your own question?
HTML Code:
for (temp.var: bids.sssssssss.getdynamicvarnames()) { |
A variable can have any number of subvariables. There needs to be some way of choosing which one.
|
if its bids.sssssssssss.weapons.sword and i use that thatwill only pull up weapons. I could use another for loop, but here comes the problem.
All I have to pass in the function is the account name of the person checking their own bids from the get go. so, bids are saved as so:this.bids.bidderacct.weapons.selleracct.itemnam e. Items selling are saved as this.items.weapons.selleracct.itemname. What I was trying to see if was possible was to use something to pass along the account name to, so i could start the var and say this.bids.bidderacct.something here, and that something here would find the rest of the var which would be weapons.selleracct.itemname, then i could use that temp.var that found the rest of the var name by something, and add this.item.temp.varsomething, that way I could correctly retrieve the info needed from the seller standpoint. In what I've tested, cant mix this with for loops. Here is what I tried. PHP Code:
PHP Code:
PHP Code:
This just comes up blank. I have a similiar senario where I use the for loops to retrieve 1 var, and all this works fine. |
I'm sorry but your system is a mess if you have to do 3 loops to get that kind of information.
Here's a different way you could store the data instead of having such a high dependency on getdynamicvars. this.auctions - Stores all current auction ids. this.auction.id - Stores auction specific data (account, category, itemname, bidder, currentbid, buyout price) Here's some barebones of what I think would be ideal for storing the information and some samples of how it would be used in the system. PHP Code:
|
Something like this be worth learning how to use graal and sqlite together instead? Im not so far in I cant just redo it anyways.
|
See the thing about my example is, by using accessors and mutators to work with your information, you can easily change it over from a DB-Flag system to SQLite with minimal trouble.
|
Quote:
A good script design is one that lets you switch out how you are accessing your data with no effect in the rest of your code. SQLite is not a solution for all problems and, in fact, is overkill 90% of the time. Designing your code like fowlplay4 just did lets you switch it over to SQLite in the future if you need to for some reason. |
Ok so I'm still going to go sqlite way, and have been messing with it for some time. Figured since its an item db, an auction house which is almost another item db, it will be needed eventually, and to go ahead and use it now.
Also just to note, all the temp.vars are full and correct. This was working perfectly find when I was using a dbnpc, so I saw no real need to post where they came from. I have this in a function PHP Code:
PHP Code:
|
Quote:
Quote:
Maybe you meant to do this? PHP Code:
|
Ok, so with this:
PHP Code:
PHP Code:
|
Your best bet is to use a wrapper class for SQL, Inverness made a nice one here. It also includes some usage which explains a little bit about SQL.
|
Nice examples in this thread, it could be sticked even. I came to a similar solution fowlplay4 is using in the 2nd iteration of my events system. It was getting ridiculous to write set/get functions for various value's so I totally redid the way I stored information.
|
| All times are GMT +2. The time now is 07:14 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.