Outlet ORM

30 01 2009

If you’ve ever tried to use an ORM to create a data layer in PHP, then you know its not always as easy as it seems. Not to mention if you actually have to change a relationship, you could be digging through thousands of lines of code for days. Not anymore, a friend of mine has created Outlet ORM, although in its early versions it’s well worth taking the time to learn.

I think that he does a fantastic job of explaining outlet:

“Outlet is an open source object-to-relational mapping tool for PHP.

It differs from other orm solutions for php in that it provides transparent, unobtrusive persistence. It does not require your entity objects to implement any interfaces or extend some sort of base class. It is also very lightweight, only a handful of classes and tools.

It uses an approach similar to hibernate in java, using proxy objects that save the data behind the scenes.”

From my experience so far its a fantastic tool to work with in PHP, it has definitely made my work in PHP quicker and more organized by creating objects for my database calls. It also takes care of saving/updating/deleting items for me in one easy call, EVEN if they relate to something else and need to be deleted. Great tool, check it out at http://www.outlet-orm.org.





Excel and C# – Easy

19 09 2008

When i was first presented with this problem, I had no idea how i was going to go about doing it, searching the internet for a little while is always my first step. Even when i get to one solution i usually keep researching to see if there is anything better, that way i at least have a few choices before I go coding in the wrong direction.

In any event, the task was to integrate a Windows Form with excel, to import data easily into another application or a database. There are a few problems with the thought of this, “how do i interact with excel” and “how do i deal with different versions?”

First lets deal with the interaction, this may not work for all version but it does with 2007 and 2003, which i can test from my laptop.

Excel is basically like using a SQL database, there are some differences on how to do things, but its easiest I found if you just import to a data table and work with the data from there, rather than trying to work through excel. (Why do that if you could just open excel anyway?) So to get it started were going to use the System.Data.OledDb assembly, make sure to add that in the “using” statements at the top.

Once we have that we want to create a new OleDbConnection:

private OleDbConnection conn;

Then down a little bit more in the constructor we want to check the version of excel they are using, i just do this by simply making a bool and basing it off of the file extension. “.xls” is 2003 and “.xlsx” is 2007, i just check that and set a string for 2007 or 2004. Once we get that out of the way we can make the connection string:

if(excelVer == "2007") {
     conn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + file + ";" + "Extended Properties=Excel 12.0;");
}
else {
     conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + file + ";" +      "Extended Properties=Excel 8.0;");
}

As you can see above there are two different connection strings for the respective versions of Excel. Based on what file they are using were going to want to change that connection string, so if you allow you user to change the file whenever they want in your application, you need to change this with it!

After that its as simple as SQL. Lets create a OleDbDataAdapter:

OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM [" + worksheetName + "$]", conn);

Then we just use da.Fill(dataTable) and we can bind that to a data grid or do whatever with it! Thats it! If you need any help, just leave a comment and i’ll do what i can to get back to you!





ASP.NET 2.0 styles don’t show up in FireFox, fix!

25 08 2008

I was stuck on this problem for the majority of the day today and it was driving my crazy, i figured i would share my particular solution with everyone. Almost every place I looked up for an answer to this question had something to say about how the server is configured wrong, when i reality it had something to do with my master page!

If you cant figure out why your styles just wont show up in Firefox see if this is a fix for you too. Check the master file, make sure that you have your stylesheet linked correctly. If all is well there make sure you do NOT have a content placeholder in your header tags. For some reason if firefox can see that content placeholder in the head it will void the rest of the tags up there except for the title tag.

This just happened to be a fix for me and i hope it can help someone else!





New XNA Goal

12 08 2008

So I’ve been thinking a lot lately about developing a game within the XNA developer studio. I’ve talked with a lot of my friends about it; friends who have also taken XNA classes with me or have been involved in that type of thing. No one seems to really have the time for anything like that at the moment. So I’ve decided to take thing into my own hands, and start a personal XNA project.

With that being said I’m going to start from the beginning, with just the ideas in my head, I’ll begin with all the planning, choosing an idea, writing it out, documents. Then from there I’ll move on to development, and eventually try to get something released.

I think whats important here is ACTUALLY DOING IT. So that’s why I’m going to start small, on hour a day, one time a week. If i get more momentum, then I will increase that. If anyone would like to collaborate with me, please send me an e-mail at: wade -AT- utahairsoft -DOT- com.





New tutorial.

1 07 2008

I know that i havent updated in a while, sorry about that. I’m still alive though so thats a good thing.

I’ve finally graduated from Neumont Uiversity and I’m out into the workforce. It’s good so far, I’m just glad that its not school! Anyway, I’ve posted a new tutorial on the well… tutorials page. It has to do with Application Unlocking your Samsung ACE, which is the phone that I currently have. It was pretty rough finding information on it so hopefully it will help someone out.

Thanks for reading, I’ll try to post more!





XNA 2D Sprite Sheet Animation Kind-of Tutorial

5 11 2007

So based on my blog stats, people are looking for a little help with 2D animation in XNA. It’s really quite simple, however getting it all to work together in a object oriented structure does take some practice. For those of you that are looking for a little help, I’m going to post the solution to my assignment for my XNA development class. If you aren’t sure what the assignment is about, check out the post below it talks all about it.

This solution basically entails all of my assignment requirements in one. It is a bomber man clone type game (which i didnt finish) and currently you can move bomberman around, plant bombs, watch them explode, and see some minor collision detection with the flame. If you run into your own flame you die. It currently only supports one player. Since it was an assignment and we moved on, I dont have time right now to continue to work on it. If anyone reading this decides to take it and make it into something better, go for it! Just make sure to mention how kind and loving I was to give it away.

On a side note, I included all the sprite sheets i found for bomberman. There is a bomberman red, green, white, black, a bomb sheet which includes bomb animations and flame animation, as well as an enemy sprite sheet, that includes all the animation for single player bomberman enemies.

The full solution can be found here: DOWNLOAD ( mirrored from my website http://www.utahairsoft.com )

Thanks for reading, and sorry for the lack of commenting in the solution. I’ll have to write an actual tutorial some day when i get some time.





XNA 2D Animations Using Sprite Sheets

12 10 2007

So my first assignment for the XNA class is to create a 2D game; Or at least create the begninning of one. I’ve decided to try and make a bomberman clone, like I said in the post before.

Either way, in order to do that were going to need sprite animating. It makes most sense to me to put this in a class somewhere, that way if we have other things other than the players that we want to animate, we’ll be able to just toss it to this class and, boom, were done. However animating a sprite sheet is a little more complicated that you’d first think. After all it’s just once giant image, with smaller images inside separated by an exact number of pixels. So that means were dealing with nothing but pixels and math. Basic math, but math none the less.

If you were to take the entire sheet, and make it into a grid to see how all the images are laid out, you probably wouldnt want to port that straight over to your game. Why? Well, generally sprite sheets have spaces between the character animations. This means if we port straight over, were going to end up with un-even spaces on all the sides of our character, and we dont necessarily want a space that big, or even a space at all.

I’ll write a tutorial on the final class, but i might as well overview it now. Basically we need to create a rectangle, one that is the same size all the time, then we grab different parts of the large sprite using the rectangles X and Y coordinates. Generally animations will remain on the same line, unless its a really long animation then we would need to deal with line breaks. Since we do not want our character to have spaces around it, we need to make sure to calculate exactly how much of the character we want, and what the space is between that so we can add it to our X and Y each time we change the frame.

I know it doesnt make much sense right now, hopefully i will have a tutorial up soon so you can see how its working i just wanted to let you know what i plan on doing next. Keep your eyes open for that!





XNA Game Development

11 10 2007

I just wanted to go ahead an update. Whenever I start something new, I instantly think about my blog. Don’t ask why, I just think it would be fun to keep track of what i’m doing, so here it is! Hopefully i will be able to write some tutorials on XNA, while I’m working though the class, that would be amazing.

In any event, i’m currently taking an XNA class at Neumont University, for our first assignment were suppose to be using 2D animation to create a simple game. A game i always thought was fun, was Bomberman, so a friend and I decided we were going to try and start making a bomberman clone, not sure on a name yet though.

Being as how i’ve just started i know next to nothing about the XNA framework so hopefully if i keep it updated here, i’ll help someone else on the road to figuring it out. If i can at least accomplish that I’ll be happy with myself.

Look for updates soon i hope to have some information about my bomberman clone soon.





MySQL Subqueries

8 03 2006

Those of you who know me i’ve been working on a website lately for a brick company. http://www.beehivebrick.com to be exact. Things are going great with it, here is a bumb in the road that in encountered that i think might help out some other PHP and MySQL programmers.

If your like me, you dont keep up on the newest and best ways to do PHP or MySQL, so you probably dont know what versions are compatable with what. With MySQL i was doing something like this at home:

SELECT * FROM images WHERE imgID NOT IN (SELECT imageID FROM relation);
-The above worked great on my home box, with MySQL version 5.0.

On the clients webserver, Lunar Pages, it didnt work. So i started looking around at what i did wrong that might be a slight difference in different versions of MySQL, well it turns out that Lunar Pages is running MySQL 4.0.25, which in turn does not support subqueries. They didnt start supporting them until v4.1, which on my home machine i have 5.0.

Anyway, the nice thing about subquieries is that they are easier to read, and formulate. I didnt have to look up a tutorial to figure out the above SQL query, i just messed around for a little until it came out right. However, to convert that to a MySQL 4.0 or less standard, or even just convert it to a non-subquery you change it into this:

SELECT * FROM `images` LEFT JOIN relation on relation.imageID=imgID WHERE imageID IS NULL;

Wow, so thats kind of a mouth full compared to the subquery above. So in the end i guess that its safe to say, i like subqueries a lot more than i like joins. Of course that seem to be a regular occurance over here at my school anyway.





C# Custom Themes

6 03 2006

While I’m here making my new blog, I might as well write my frist actual post.

When I first started school here at Neumont in October 2004, we were pushed right into learning C#. This was great, I’ve always been a fan of the Microsoft programming languages. So anyway, needless to say we got fairly savvy with C#. Since the last two quarters we’ve been doing nothing but Java I’ve become rusty… I know its a sad thing but its okay, i’ll try to get it  back.

 Okay, so what exactly spawned this post, and the reclamation of a new blog in the first place? Well……. Simply because i’ve been doing a lot of thinking about applications lately, and frankly, the one thing that makes an application great is its theme. Really you can have the most simple application, even a addition only calculator, but as long as it has a nice theme, people will think its great. (Well aside from it not crashing as well…) In any event i’ve been looking around and i haven’t been able to find anything on C# custom themes. Sure its easy to add EnableVisualStyles() to any of my programs, but i want something more unique than that.

This is more to inform people that I’m looking or that i want help finding something like this, maybe someone will come along and give me a nice link to some class library that i haven’t found yet. In any event im going to start working on somthing like this i think, so i’ll post here as i figure stuff out about it.

Thanks for taking the time to read my blog, its not much yet but whether you read it or not im going to keep doing it so ha! ;)