-
Posts
1,172 -
Joined
-
Last visited
Posts posted by boo_lolly
-
-
@Psycho,
Thanks for your quick reply!
Your first query does what it says, but not what I need. The issue is that we cannot simply grab all that don't match. We must grab records from the food_tags table that have a specific set of food ids. Otherwise we would be deleting several records for several other foods based on additional criteria from the food_tags table which we do not want to do. It must be a specific set of food ids. Hence the initial SELECT * FROM `food_tags` WHERE `food_id` IN (...
Think of it like narrowing down the food ids list rather than simply grabbing all that don't match a specific criteria.
However, I believe your second query does in fact grab a specific list of only matching food ids. I will test that out and see if this is the case.
In response to your initial question - the goal is the migrate the database schema incrementally to accommodate this.
-
In short, I have have a table `foods` that has duplicates on occasion. I have another associated table `food_tags` that has tags associated with the foods listed in the `foods` table.**Objective:** I want to retrieve the records from the `food_tags` table for all duplicates found in the `foods` table except for the *first* records in the `foods` table (the records with the lowest `id` value).SQL Fiddle - http://sqlfiddle.com/#!9/ee1c6/2I have a working example of what I want but I'm almost certain this is not the best way to do it. Here's what I have:
SELECT
*
FROM
`food_tags`
WHERE
`food_id`
IN (
SELECT
`id`
FROM
`foods`
WHERE
`id`
NOT IN (
SELECT
MIN(`id`)
FROM
`foods`
GROUP BY
`name`
)
)Basically I want to exclude the first record of the duplicates in the `foods` table (the one with the lowest `id`), but retrieve all the remaining duplicates and then get the results from the `food_tags` table based on the `food_id` of the duplicates.I'm very curious to see what your ideas are on how to solve this problem and the best way to approach it based on the constraints.**Additional Information:** Ultimately the goal is to delete these records, along with other records in other tables based on the same criteria. I realize that there are ways you can setup the schema or normalize the database to handle duplicate entries and automatic deletions of records from one table based on deletions in another related table. For the sake of the issue, let's assume that these options are not available.Thanks in advance for your time and insight.
-
Of course you get to plan it, you're the developer! But as soon as your company starts eating the cost of the project just to make sure your code is structured and documented properly and everybody's adhering to the coding standards of the framework, your boss will tell you none of that shit matters anymore, get the project out the door, I don't care how it looks. THE CLIENT WILL PROBABLY NEVER LOOK AT YOUR CODE AND EVEN IF THEY DO, THEY WON'T BE ABLE TO TELL IF IT'S GOOD OR NOT.
-
Jaguar, you're right, but I was mainly talking about the freelance business environment where YOU are the boss, not a code-monkey drillin out syntax for the man.
In any sense though, the purpose of a framework is to make it easier for you to perform all tasks, or easier to collaborate with others when dividing tasks. Popular frameworks are more documented because they HAVE to be (there's a LOT more ground to cover). More thoroughly tested? No. Not if you grab the same code and change it a bit to fit your needs... It's even better, actually. It also doesn't matter if others have zero experience with a totally custom framework... there's a good chance it's easier to use than all the other ones out there, it makes more sense, it's super light-weight, and therefore easier to learn/work with. Nobody starts out with 100% experience in any framework. There is always a learning curve, and I think one of the main goals for most popular frameworks is how EASY they are to get started, learn, and use. If that's the case, then you must see how downloading, installing, configuring, and using a popular framework is always heavier than you'll ever require, and eventually won't be the perfect solution to a project, and you spent so much time trying to learn how to make it be the perfect solution for all projects. Sometimes... you guys gotta write procedural code. And that's why light-weight/custom frameworks are best... they are pluggable in the way that YOU want them to be. Not mandatory to install the whole thing if you want to use ONE cool feature. Strip it down to that one cool feature, and toss it into your own framework. I promise you'll get over your own learning curve a LOT faster than someone else's.
-
I've used all kinds of web-frameworks with all kinds of different languages over the past 5-6 years. Here's what I've learned... None of them are as good as yours would be if you just wrote your own. It's really ... really not that hard. It'll be for sure at most 1/10th the size of most frameworks. They are so heavy with features you'll never use to their full potential, so it naturally loads 50% more code than you'll ever tap into, which slows down page loading time even for low-traffic sites.
By the time you use, test, learn, break, and fix a bunch of frameworks, you can pick and choose the procedures you liked the most out of all of them. Grab different blocks of code from each, maybe even some from snipplr.com, strip them down and rewrite them, and before you know it, you've got a really awesome little framework that works for YOU, and doesn't focus on being so robust and user-friendly it can be used by a total idiot (which is a factor contributing the weight of most frameworks).
I have built many websites for many purposes and have taken each opportunity to either test a new software/framework/language, or refine my own php framework. I possess now what I feel is the best possible framework for every type of website. It includes fast and simple methods for database queries, clean urls, templating, user authentication (session, cookie, and database), form error handling and processing (both server-side and client-side), a bunch of jquery features that are pre-templated and simple to integrate... it's really sexy.
Besides, there's no use in pursuing the study of frameworks for anything other than creating your own because businesses and developers that take the initiative to really understand the inner-workings of a framework and take pride in their ability to push it to the next level and advertise this service in hopes that it'll help them find a niche market... Well, all they did is get better at something some other team developed... for their purposes... not yours. Not YOUR niche market... So why not take what they did right, and ONLY what they did right, and apply it to your preferred process?
I don't know about you but I got into this business for two reasons: to make money and write beautiful code... in that order. Most developers go about it the opposite way and end up the average under-compensated, under-appreciated, under-challenged, and disgruntled techie. And we have all come across the client that (before you) has in the past been swindled into a $12,000 website and it looks like it was built in 19diggitydoo with the most archaic features.
Take that as a lesson. The client NEVER knows more about the web than you, so it's really just about your ability to sell a particular process or software that will determine if you'll land the project or not. As far as the client is concerned, it has nothing to do with the process or the software itself, again, because they never know more about their website than you do. They're not going to look at the code. Why would they? They wouldn't know how to interpret it, that's why they hired you in the first place! So work on your own simple, light-weight framework that works for YOU, while most frameworks will tell you "you must abide by our rules... that's how you get the most out of it..." Screw that! Programmers are clever, creative, and innovative, especially when it comes to programming stuff for themselves. So try them all, test them all, pitch them all to your clients or even for yourself. You'll probably like some features, and hate others. In the grander scheme of things, you'll inevitably encounter a project where the framework you've chosen to dedicate yourself to is NOT the best solution. Program your own, pitch your own with confidence, and get rich faster.
Cheers
-
As the title indicates, I'm looking for all the required config variable settings, htaccess conditions and rewrites, etc. Basically, I'm looking for all opinions and examples because I'm almost positive I'll miss something the first time. So far, I've reviewed and slightly understood the validity of the following solutions:
http://codeigniter.com/forums/viewthread/86113/
http://stackoverflow.com/questions/1818869/htaccess-https-to-http
I'm not sure which applies to me, since several options are available. But the kicker is that it's hosted on a client's GoDaddy shared hosting account, and for some reason, "index.php" in the url doesn't work... it MUST be "index.php?" in the url, otherwise it just brings up a "No input file specified" error. It's BS. Anyway can I get some assistance here? Thanks in advance.
-
pbs,
THAT TOTALLY WORKED!
I can see that I had an extra closing parenthesis at the end that was not necessary and the opening parenthesis right after VALUES was also not necessary
-
I cannot for the life of me figure this out. PhpMyAdmin puts there error somewhere around the word VALUES.
INSERT INTO `tasks` ( `id`, `challenge_id`, `title`, `frequency`, `category`, `description` ) VALUES ( ( "", 12, "title1", "frequency1", "category1", "somedesc1" ), ( "", 12, "title2", "frequency2", "category2", "somedesc2" ), ( "", 12, "title3", "frequency3", "category3", "somedesc3" ) );
I have not left out any columns in the query on the table `tasks`. Can anyone else see what i'm doing wrong? I've been banging my head over this for like an hour...
-
Alright so the problem was not Wordpress, it wasn't .htaccess, it wasn't the subdirectory permissions, it was a centos server thing. If there's nothing inside the directory, it'll automatically bring up a 403 error. As soon as I put a blank index.php file in there, everything was fine.
-
Hey all,
I have a Wordpress installation (inside the root directory) that uses a .htaccess file to have clean urls for posts and pages. It looks like this:
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress
However, I want to add a subdirectory inside this wordpress installation so I can add other stuff or another app or whatever I want and still access it. So to verify, wordpress is here: http://www.mydomain.com/, and my subdirectory is here: http://www.mydomain.com/subdir/. However, when I go to my subdirectory in my web-browser I get a 403 error:
Forbidden You don't have permission to access /subdir/ on this server.
I know that the permissions to this directory are just fine (777 just to be sure) and I still get the same error. How can I write a rule or condition in my .htaccess file that will allow normal use of this directory??
-
I'm trying to figure out the easiest and best way to have a little bit of javascript functionality. So let's say for example I have a page like this:
<div id="copy"></div> <input type="text" name="userinput" />
I would like the div to display the text of whatever the end user is typing in the input field while end user is typing it in real time seamlessly. I'm sure there is no need for a javascript toolkit or framework for this one, but I'm already using jQuery with this project so if you decide to submit a working example using jQuery by all means do. Any help, resources, or advice is welcomed. Thanks!
-
-
This is a bit tough to explain without screenshots. I need a div element to stay at the bottom of the user's browser screen as they scroll down the page, but once the div element has reached the bottom of its container element, the inside (footer) div should stop and stay there while allow the user scrolls down to view the rest of the page. Also, if the user is scrolling all the way up, then as soon as the inside (footer) element hits the bottom of the user's browser, it will stay at the bottom of the browser until it reaches the top of its container element, there it will stop and the user can continue to browse toward the top of the page.
An example of this can be seen at http://www.mininova.org/ Look to the right at the advertisement. As you scroll down, it follows, then when you get close to the bottom of the page, it stops before you scroll all the way to the bottom. I want the same effect, except I want the element will be horizontal, and in the middle of the page. Can anyone help me with this effect?
From the research i've done it looks like it's a combination of relative and fixed positioning.
-
-
I'm looking for a set of relational database tables that have Countries, States, Cities, and Zipcodes, all related in some way for reference. Anyone have this, seen this? Or found something I could work with? I'm thinking maybe a shopping cart might have something like this on installation? Anyone have any leads to a free countries -> states -> cities -> zipcode existing relational database?
-
I'm looking for a set of relational database tables that have Countries, States, Cities, and Zipcodes, all related in some way for reference using a programming language such as PHP. Anyone have this, seen this? Or found something I could work with?
-
I found a great deal of information from that link. Thanks!
first, for a commercial ip/geo-locator service you can go to http://www.maxmind.com/app/geolocation which is known to be incredibly accurate.
second, for a free ip/geo-locator service you can use a very simple http request using http://www.hostip.info/use.html . This website is not always accurate. however, when it encounters an ip that it can't locate, it requests the end user to provide their location. Don't you just love open-source?
Thanks again!
-
I'm trying to see how to write a script that can read the current user's IP, and reverse check to see the physical location (country, city, state, zip... whatever I can get) of the current user. I've seen a couple of sketchy sites that do it out there, already, but I need this information to be calculated on my server so I can store this information into a database, along with the IP address, simultaneously. So I was wondering, first, if it would be better to write this script on my own, or if I should use curl to communicate with one of the websites that can already does this. Second, how would I do either one of them? Not familiar at all with curl, and I'm not sure where to begin if I were to write it myself.
The most useful of the websites I have found that do this is here: http://www.find-ip-address.org/ (it's pretty accurate. gets me within 10 miles of my actual current location.)
Can I get some help with this?
-
I did something like that before and it works, yeah, but ontop of printing the file, it also assumes you want to download it, or view it in your web-browser... whichever the browser settings may be, it performs an extra operation, which I'm looking to avoid.
could I add a hidden iFrame embedded in the page? and have a link to print whatever is inside the frame?
-
Hey guys. As the topic describes, I'm trying to use the javascript onClick tool to print an external file, not the current (or any other) HTML page. I'm wondering if I can do this without having to write a custom javascript function. If so, I imagine it wouldn't be too difficult. Like writing a function that takes the path-to-file as a parameter, and then when using it it would look something like
<a href="#" onClick="printdocument('http://mydomain.com/docs/file.pdf');">print file</a>
However, I'm not sure if javascript already has a built-in function for this. Maybe something like
<a href="#" onClick="document.location('http://mydomain.com/docs/file.pdf').print();">print file</a>
Can anyone help me with this?
-
I have no idea why this is so difficult. I've been doing this for years and I cannot figure out what I'm doing wrong.
I run ubuntu hardy and i do not see mail enabled in phpinfo(). I have my php.ini settings correct. I restart the server and it still doesn't have mail enabled. I try sending test emails and I get an error.
Where do I go from here?
-
I tried almost all the PHP frameworks, and I'm no newbie to programming or PHP. What I determined throughout this tryout process was that you have to ask yourself what do you want in a framework? What's important to you? What common PHP tasks are most tedious?
For me, I wanted the usual MVC approach, EASY installation (practically drag-n-drop), form validation, clean urls, loose modular design so it is easy to take applications from one site and move it to another, and scaffolding. Another thing I think is REALLY important to consider is this... Frameworks are used to make things easy... well, what if half of your site is static content, or a simple contact form that emails the message on form submission? Many frameworks make these otherwise simple tasks very difficult.
After testing and inspecting syntax and code logic, I decided that codeigniter was the best php framework around. The only thing it doesn't have that I'd like is an object relational mapper. To me, this isn't necessary, but it is a good perk.
Basically, I compare all the frameworks I use to Django. Django is a Python web-framework that I love and makes total sense to me. If you google it, it's more popular than ruby on rails, and practically more popular than any web-framework every created, for any language. And it's the youngest framework, I might add. So when I use a framework, I compare it to Django. And CodeIgniter makes the most sense, and it's the most like Django.
CakePHP, Zend, Yii, they all take too long to install and get crackin. Seriously, all you have to do to install CodeIgniter is to just unzip it, and drop it in your server. boom, it works. That's my opinion.
-
I misunderstood what the problem was. I thought you weren't getting anymore code errors, but that the php wasn't printing the html properly so the page looked messed up. my bad.
OK I understand what's happening, and I think I know how to fix it. Here's what's happening. In your controller file, you're only sending the variables $sort_column and $sort_order if someone has clicked one of the links to sort the list... But if someone is visiting the page for the first time, and has not chosen to sort a column, then it doesn't send those variables.
so basically, http://sykotic-designz.org/index.php/firstdown/sort/name/asc should work... but http://sykotic-designz.org/index.php/firstdown/ will bring you an error. This means that we need to have a default value for $sort_column and $sort_order, just in case the person using the webpage hasn't yet chosen to sort the list in any particular order. We do this in the controller file. But, it's important that the default values are NOT name, cmp, att, pct, yds, etc etc... NOR can the default values be asc or desc. So we'll just set them to some string that does not apply to anything regarding the list like 'default1' and 'default2'. replace your controller with this:
<?php class FirstDown extends Controller { function FirstDown() { parent::Controller(); } function index() { $data['title'] = "First Down Statistics"; $this->db->where('id', $this->uri->segment(3)); if ($this->uri->segment(2) == 'sort' && $this->uri->segment(3) && $this->uri->segment(4)) { switch ($this->uri->segment(3)) { case 'name': $this->db->orderby("lastname", $this->uri->segment(4)); break; case 'smp': $this->db->orderby("smp", $this->uri->segment(4)); break; case 'att': $this->db->orderby("att", $this->uri->segment(4)); break; case 'pct': $this->db->orderby("pct", $this->uri->segment(4)); break; case 'yds': $this->db->orderby("yds", $this->uri->segment(4)); break; case 'ypa': $this->db->orderby("ypa", $this->uri->segment(4)); break; // case 'etc, etc etc etc... } } $data['sort_column'] = (($this->uri->segment(3)) ? ($this->uri->segment(3)) : ('default')); $data['sort_order'] = (($this->uri->segment(4)) ? ($this->uri->segment(4)) : ('default')); $data['query'] = $this->db->get('firstdown'); $this->load->view('firstdown', $data); } } ?>
-
can you pot the html syntax that IS being displayed?
Get rows from table "B" based on duplicates in related table "A" excluding original record of the duplicates in MySQL
in MySQL Help
Posted · Edited by boo_lolly
Unfortunately the second query does not work because MySQL will not delete from a table that you are performing joins on in a SELECT sub-query. For example
This does not work. Error message: You can't specify target table 'food_tags' for update in FROM clause
Also it doesn't alleviate the fact that it has 2 SELECT sub-queries which I'm trying to avoid if at all possible for performance reasons.