Jump to content
Larry Ullman's Book Forums

Search the Community

Showing results for tags 'procedural'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Single Editions
    • Modern Javascript: Develop and Design
    • The Yii Book
    • Effortless Flex 4 Development
    • Building a Web Site with Ajax: Visual QuickProject
    • Ruby: Visual QuickStart Guide
    • C++ Programming: Visual QuickStart Guide
    • C Programming: Visual QuickStart Guide
    • Adobe AIR: Visual QuickPro Guide
  • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (5th Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (4th Edition)
    • PHP 6 and MySQL 5 for Dynamic Web Sites: Visual QuickPro Guide (3rd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (2nd Edition)
    • PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide (1st Edition)
  • PHP for the Web: Visual QuickStart Guide
    • PHP for the Web: Visual QuickStart Guide (5th Edition)
    • PHP for the Web: Visual QuickStart Guide (4th Edition)
    • PHP for the Web: Visual QuickStart Guide (3rd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (2nd Edition)
    • PHP for the World Wide Web: Visual QuickStart Guide (1st Edition)
  • Effortless E-commerce with PHP and MySQL
    • Effortless E-Commerce with PHP and MySQL (2nd Edition)
    • Effortless E-Commerce with PHP and MySQL
  • PHP Advanced: Visual QuickPro Guide
    • PHP Advanced and Object-Oriented Programming: Visual QuickPro Guide (3rd Edition)
    • PHP 5 Advanced: Visual QuickPro Guide (2nd Edition)
    • PHP Advanced: Visual QuickPro Guide
  • MySQL: Visual QuickStart Guide
    • MySQL: Visual QuickStart Guide (2nd Edition)
    • MySQL: Visual QuickStart Guide (1st Edition)
  • Other
    • Announcements
    • Newsletter, Blog, and Other Topics
    • Forum Issues
    • Social

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Found 3 results

  1. In this example why does the procedural way fail with this error: Error: Warning: mysql_fetch_assoc() expects parameter 1 to be resource, object given in /Users/joel/Sites/people_test/public_html/index.php on line 14 PHP: $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() ); $q = "SELECT first_name, last_name FROM person LIMIT 0,30"; $r = mysqli_query($dbc, $q); Procedural: while($data = mysql_fetch_assoc($r)) { $rows[] = $data; } //prints out null echo json_encode($rows); OOP: while($data = $r->fetch_assoc()) { $rows[] = $data; } echo json_encode($rows); I thought I was doing the procedural way right from reading the PHP.net fetch_assoc() procedural and oop examples. Obviously I'm missing something. Could use some help seeing what it is.
  2. version 0.5 Page 129 As I read this book, I keep scratching my head, wondering what's so good about OOP (Object Oriented Programming). The clips example is a case in point. Why write 5 lines of code when you can write just 2, like this? $stockQuote = 'AAPL: $533.25'; echo $stockQuote; I can modularize my procedural code by using includes. So how can all the fuss and bother of OOP be worthwhile? I've read plenty of rationales defending OOP, written by people who studied it in college, but it seems more like a religion to me. Sorry, I don't mean to offend anyone. I've read some books on OOP php, and I'm patiently reading through this one, only because I want to take advantage of the code that's automatically generated and tailored to whatever tables I need. But frankly, I will probably write most custom code, queries etc, as procedural php.
  3. Hello Larry, Thank you for all your help, I learned many things reading your books and now I am back to the desk for learning after many hours of producing. You were right that a programmer may have a very nice life doing procedural programming and I have to say that I finished a quite big project and I didn't mind 'repeating myself' as in fact was not that bad, put things in functions and the repeating part was rather easy: copy/paste and changing a few things. I like the fact that I can keep things separate, HTML, SQL, PHP, CSS. Anyway... I've got so used with your way and the patterns I learned from book that now I have a question related OOP. Is it a mistake if I use the same structure, for example the "configuration" file and the "connection" file and simply rewrite in oop syntax? Especially the database connection file that usually in frameworks does not stay outside the "http" folder. if I do write, let's say, a validation class for forms and for some project this is all that I need, is it a mistake that I do not create a CRUD class and other things like a framework has? I know it sounds like reinventing the wheel, but it is not quite like that. An existing framework has a lot of things that are useless to small projects and require maintenance that small projects do not necessary need. Why should I have the forms, for example, generated from PHP when, maybe, as part as my workflow, I prefer have them in HTML, so I can see them and work visually, like in Dreamweaver. I guess many with a background in design and not in programming would prefer it this way. Let's take for example Dreamweaver, it has some basic things that can do "programming for poets" and it is really fast, but it lacks a server side validation script. A simple validation class to resolve this issue will resolve a lot of problems and speed up the development. Will this be a bad thing ("unprofessional")? I look at your "Shopping Cart Widget" class in the book. You do not actually create a very general class and extend it afterwards in a framework style. It performs pretty particular things and probably can be abstracted more (a guess). Is that example just for study (as it compares with the procedural code before) or it may really be a production piece of code? If you add, let's say, real time quotes from Fedex, is it necessary to write a class "ShippingClass" than extend it with "ShippingFedexClass" when, assuming it is possible, writting just a functio in your Shopping Cart Widget class may provide shipping quotes? Bottom line, if we do not have very abstractizied classes for everything and keep things separate (things like forms, I believe this is a very good example), is this a mistake? Is it possible to have the best of both worlds? Thank you, Greg
×
×
  • Create New...