Welcome Guest, Not a member yet? Register   Sign In
CI related SaaS Questions
#1

[eluser]Adam Griffiths[/eluser]
I am planning to offer Software as a Service and have come across one problem which I will ask about now...Smile

This app is for estate agents, that's about all I can say. So, each user should login via their company "website" i.e. companyname.mydomain.com - and then have their own usernames and passwords and can only login from that site. Then everything after that will still be on this site.

I was thinking about using .htaccess in such a way so it will cover up the fact that there isn't actually subdomains. I have seen another thread in which the OP asked how they could get their URI structure like username/class/function/params and think this would work well. Are there any other ways (better/more efficient?) to do this? I have seen some people using hooks to do this, I think I would need to use a hook to get the company id (see below) to reference the users etc by storing it in a global variable available to the app. Could somebody possibly give a rough idea of how I would go about implementing a hook? I could do it totally on my own but I'd probably break something and end up here anyways. Smile



I would like some advice on my database plan. The plan is to have a database to hold all of the Estate Agents company information. Then their unique ID would be used for all the subsequent users, something like.

Code:
SELECT * FROM users WHERE `company_id` = '1'

And as such this would be used throughout the application, for each addition they make, have an ID in the database table somewhere so I can link it back to that one company.

In regards to the database, would this be the way you would do it? If you've done it before like this, can you share anything with me that you wish you'd known beforehand? Some pitfalls to watch out for and to not fall into any traps?

I have been studying databases in college for some months now and am very aware of most pitfalls in database design and construction. I know a lot about normalisation and correctly linking fields etc, but I am just wondering if the way I plan to do it would get messy? Like losing track of what the hell all the numbers mean? I brought this query up with my databases tutor and all he told me was "the user will only see the attributed data, because access gets it from the other fields." I asked about the best way to tackle writing an app for a database and he couldn't answer me (I'm so glad we have a new tutor). So any comments on this part is greatly appreciated.


Also every estate agent will have an external website only linked to the app via a search tool. I am going to need some sort of API to create this outside functionality. I know CI doesn't allow GET requests but I think I have seen some others on the forum doing this, I will try a few of the ways I have already seen but I have some questions. As I only need one controller to have a query string type URL, I am a bit weary of doing the following.

Code:
$config['enable_query_strings'] = TRUE;
$config['uri_protocol'] = 'PATH_INFO'; // Anything but AUTO or QUERY_STRING

I am unsure of what the PATH_INFO actually does, and what it would do to the clean URI structure CI has. If I had a URL which looked like this:- http://www.myapp.com/search/?type=detatc...&bedroms=2 how would I reference each value in the query string-esque part of the URL. How would I route the search part to the search controller. How would setting the above config values affect my URI structures throughout my application? Can I still use the clean URI structure? Will my app also be available via a query string URL? Is there any other way to get a query string in my URI structure?

Plus I've never written an API before so, once again, any comments on things to avoid, possible security holes to close etc is appreciated.


This thread is getting a bit long now so I will leave it there.

Thank you to anybody who responds.


- Adam
#2

[eluser]Adam Griffiths[/eluser]
Ok, I realised that my initial post was quite large, here is the shorter version. Smile

1) How can I get CI to give me a username.domainname.ext structure? Possibly using hooks?
2) The app will be a bit like basecamp, where everything is linked to a company. Having an ID for each company in each table is the way I'm thinking of having my database setup to link everything to the company. Is this the best route?
3) How would you link the company table to other tables? Use numbers as a primary key or a string? Or something else?
4) I need to have a search API available to external websites, (see url below), how can I get this with CI?

Code:
http://search.mydomain.com/?agent=estatesuk&type=detatched&bedrooms=4

5) By changing the $config['uri_protocol'] and $config['enable_query_strings'], how would I access the URI parts?
6) Can I still use the clean URI structure if I change the above 2 config items?
7) Is there anything I should look out for when developing an API?


-Adam
#3

[eluser]Michael Wales[/eluser]
1. Depends on your host - many hosts will be willing to setup a wildcard DNS that will make your subdomain (ther username) just another parameter within the URI

2. That's definitely what I would do. I'm thinking of an accounts table, so you can manage accounts and the company information, and then actual user accounts (and all subsequent content) will reference that accounts table.

3. Using unique IDs would be more than sufficient - a lot of JOINS using the table's primary keys, for instance a comment on a photo might look like this:
Code:
id INT NOT NULL AUTO_INCREMENT PRIMARY KEY //This comments ID
photo_ID INT NOT NULL // The photo in which you are commenting
user_id INT NOT NULL // The ID of the user commenting
account_id INT NOT NULL // The top-level account all of this content is in, could be omitted since the photo would have this
comment TEXT // The actual comment
created_on DATETIME

4-6. Unfortunately I can't really help out here, I've always used clean URLs.

7. Elliot Haughin has a great post on developing an API using XML-RPC, check it out: http://www.haughin.com/2008/05/29/buildi...h-xml-rpc/
#4

[eluser]Adam Griffiths[/eluser]
Thanks for the reply Michael. Your comments are much appreciated, and thanks for the link to Elliots blog post. I found a few threads on the forum, I will play around with the ways to do 4-6 later.
#5

[eluser]Adam Griffiths[/eluser]
I have had a play around with enabling query strings and have found that with ORIG_PATH_INFO I can only use query strings but when using REQUEST_URI I can use both clean URI's and query strings, but not both. Is there a way I can use both? Or would I need to create a function to loop through the segment and strip the data from it?




Theme © iAndrew 2016 - Forum software by © MyBB