Jump to content
Larry Ullman's Book Forums

Antonio Conte

  • Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by Antonio Conte

  1. You better check it out, Jon. I recently implemented a shopping cart solution in under 500 lines of application code. While it was really limited to functionality, it had support for Users, categories, products, sales and general cart functionality. Throw a Stripe facade on top of that (I recently implemented one) and you have a functional Ecommerce-solution. No need to code anymore really. The packages used where Sentry, (for User auth) Eloquent (The awesome ORM shipped with Laravel). The job I built this for fell through, but I gained invaluable experience. Composer can't get enough
  2. Check your primary key size settings on your tables. I.e INT(11). I had a similar problem a couple of years ago, and allowing larger integers solved the problem. Try doing a manual insert into the DB using PHPMyAdmin.
  3. Also remember that PHP is an interpreted language. That means that PHP code is executed by a interpreter, not from a compiled source. The file extension .php has no special functionality. The interpreter might also run .html, .txt or .randomExtension as PHP if you can just tell PHP and Apache to treat it that way. This article might clear some things up: http://php.about.com/od/advancedphp/p/html_php.htm
  4. I've been using composer for a while know, but I felt like participating a little bit too. On a hobby project I needed a priorityQueue, and noticed SPL had one. The problem was that it would dequeue values in random order if several nodes share the same priority. Usually, this is considered a bug for a PriorityQueue, so I decided to fix that. Here the very small ThomasLarsson/PriorityQueue hosted on Packagist! And here's a small preview of how I'm using the package. Anyone else played around with composer, submitted a package or think this is interesting?
  5. Another solution to the problem would be to save the div name to a variable outside of the loop, and run a simple if-clause against it. An example could be. $header = false; $group = false; foreach ( $menuRows as $section => $type ) { // Check if header is equal to last if ( $header && $header !== $type['div_name'] ) { echo $type['div_name']; } // Check group if ( $group && $group !== $type['grp_name'] ) { echo "<tr><th>" . $type['grp_name'] . "</th><th> </th><th> </th><th> </th></tr>"; } //
  6. The short answer is yes. Without looking at any code, and from your description, a recursive function might do. The "problem" might also be that you structure you data in a bad way, so that you are forced to work with recursive functions. I can only speculate, but I do believe such a problem should be solvable without recursion. I would at least look into that before settling on your current solution. Give us some database structures, example data and code to work with if you need further help.
  7. Textmate has gained much "hype" recently due to experienced developers Using it alongside the command line in YouTube learning videos. What it boils down to is efficiency, and most would gain from using an IDE in that regard. NetBeans checks my code, generates Class skeletons, runs my tests, generates my Apis, formats my code, push code to github, uploads to my server Using FTP and has my favorite shortcuts for code generation. It also has built in support for all languages I program in. Textmate can't beat that. IDEs are not for everyone though. I would at least recommend you giving o
  8. A good technique you can pick up from the MVC pattern is how you should structure your code. When I program procedurally, I generally never include HTML before the end of the document. That way, you can keep logic and the rending of HTML separate. You can try to make your program follow these steps: 1. Include/require all the libraries, files with functions, etc you need. 2. Call functions and save their results to variables 3. Determine what "view" (i.e login error view or successful user dashboard) 4. Include (render) the views for the page. <?php // 1. Require needed files req
  9. phpstuff: Stop immediately and download Eclipse, Netbeans or another of the free IDEs. It's totally worth it.
  10. I'm mearly guessing here, but I think the index will really only slow down your INSERT / UPDATE queries, but not affect SELECT or DELETE. Slow inserts are often not really problematic — it's the select queries you want to go fast. Another guess would be that SELECT queries will actually be quicker due to your index, as indexes builds binary trees (b-trees) on your data. It's pretty much boils down to this: How does SELECT queries against the 15 columned uniquely indexed table compared to other queries to other tables? You'll get execution times in PHPMyAdmin. Larry might know more abo
  11. It's ok and nothing really unusual to do. If it should be unique, add indexes as necassary. DBMS are incredible potent, and you don't really need to focus heavily on performance unless you work with really large data. A good tip is to focus on data integrity first, then focus on performance if things start going slow. The "correct" way here would be to work with IDs rather than names, but unless you need the three tables dogs, kennels and breeders, you don't really need to enforce that. The principle is called normalization, and teaches you how data should be split into the correct table e
  12. You can find some good information here: http://dev.mysql.com/doc/refman/5.0/en/create-index.html To give you an example on last name, you could do something like this: CREATE INDEX partially_lastname_index ON users (lastname(5)); Keep in mind that you are mainly saving diskspace limiting the index. Unless that's important, you'd generally want to index the whole column. I trust that you've already done some research though.
  13. There is no "YII best practice". This is totally related to CSS, HTML and front-end design, and has nothing to do with YII or PHP in general. The way you want to do this is by overriding CSS. CSS is read top-to-bottom, and newer (declared later) )CSS properties overwrites older ones. (more to the top) I'll give you a concrete example using main.css and style.css. main.css: .something { margin: 10px; border: 1px gray; color: blue; } style.css: .something { margin: 15px; border: 1px black; padding: 5px; } If style.css is loaded later in the HTML file than main.css
  14. A quick tip is to apply some debugging. $permission = $user->canEditPage(new Page($_GET['id'] )); var_dump($permission); if( ! $permission ) { header("Location:index.php"); exit(); } What does something like that give you?
  15. You should really be using composer rather than downloading manually. It probably has lots of dependences, and it would be a pain in the butt to keep it all up-to-date. The composer.json here: https://github.com/zendframework/ZendSearch/blob/master/composer.json
  16. This is my .htaccess for Codeigniter: RewriteEngine on RewriteCond $1 !^(index\.php|images|assets|uploads|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] It routes everything to index.php (remote index.php in CI config) but ignores the folders images, assets and uploads. Give it a shot.
  17. Nice you got it working. Also, don't sweat it too much. There's always "some better way" to do things, but we must all start out somewhere. Gradually improve your code as you learn more, and make sure to enjoy the learning processes. I'll take some time to explain the query now. Some part of the key is the aliasing. When you use several tables in a query, adding the AS alias is often required. When a column has the same name in several tables (as your student_no) MySQL will need to know which table the column is in. The same is true for aggregation functions (UPPER(column)) as echo $ro
  18. A better way to do this would be to write a more advanced query. That way, you can get more information from a single query. // Build query $query = "SELECT student.*, UPPER(student.school) AS uschool, UPPER(student.campus) AS ucampus, COUNT(course.student_no) AS attempts, COUNT(scores.student_no) AS attendance FROM student AS student LEFT OUTER JOIN course_attendance AS course ON (student.student_no = course.student_no) LEFT OUTER JOIN toeic_scores AS scores ON (student.student_no = scores.student_no) WHERE student.student_no = $id ORDER BY $order ASC"; // Get result $result = mysqli_q
  19. You over think performance gains here. Don't focus on the 5% optimizations, but those that really drag your execution time down. The keyword in that regard is loops. If you write a function that iterate an array once, your performance is called O(N). If execution on 1000 array Elements is 3 seconds, doubling to 2000 will execute in 6 (linear increase). If you nest another loop into your first, you'll get O(N2). If 1000 elements takes 3 seconds, 2000 will take 9. (Exponential growth) Nest even one more, and you'll have an exponential growth. If 1000 elements takes 3 seconds, 2000 will take
  20. Go into the structure view in phpmyadmin and change both to lowercase. Why would you ever let the structures differ anyway?
  21. Sure the code reponsible for that is not in register-thanks.php? I see nothing that would send an email here.
  22. Method overloading is such a beautiful tool, and I really wish PHP could implement it. Such a shame.
  23. Ok. I will check it out. I've provided a workaround be using one of the cookies that stores the user id. Using that, I simply do a query against phpBB3 to get the needed information. While I know this is not secure by any stretch of the imagination, the information returned is harmless, and only includes username, birthday and email_address - all public information non-the-less. The solution will work until I figure out how to make the cURL request work. EDIT: I've almost managed to make this work. The first time I load the page after the cURL request, the correct data is returned. Ho
  • Create New...