|laziness, impatience, and hubris|
Re: PerlOO what i am doing???by xyzzy (Pilgrim)
|on Aug 12, 2012 at 01:23 UTC||Need Help??|
What are you doing???
You have a constructor that doesn't do anything. Normally it would perform actions necessary to set up the object, for instance if your object was the database, the constructor might attempt to open a connection and store a handle to the database, as well as provide a mechanism for catching and reporting errors that occur.
You have a bunch of unfinished and unstarted methods. And then the methods that you do have are procedural and don't really fit with the OO paradigm.
Before you go any further, you should look up information about Object Oriented Programming, learn about abstraction, encapsulation, the difference between classes and objects, the relationship between objects and methods, etc. Then, only when you understand how OOP works, if you are working on a project that relies heavily on a database, I highly recommend DBIx::Class, a module that provides an object-oriented interface to a relational database (it is compatible with many backends, including MySQL). This will eliminate the need for SQL and it can generate classes with accessors and relationship mapping for all of your tables in a way that is intuitive and easy to understand. Right now your code, aside from being messy, wasteful, and mind-bogglingly obtuse, is vulnerable to SQL injection attacks (what will happen if I call $database->check_comment_record('1; drop table comment_record')?). Using DBIx::Class will solve these problems for you without you having to know anything about database security. Creating new records is as easy as
You have a lot of reading to do before you can even try to do something like this. Wikipedia is an OK place to start. There are certain websites where you can obtain pdf copies of books about database programming. The CPAN documentation for DBI modules will be helpful if you sit down and read it very carefully. When you have enough of an idea about what you're doing to ask an actual question you can come back. The community here would be glad to help you, but only if you actually show us that you are someone who knows how to RTFM, use Google, and that you can figure basic things out on your own before asking for help with a specific issue or problem.
$,=qq.\n.;print q.\/\/____\/.,q./\ \ / / \\.,q. /_/__.,q..
Happy, sober, smart: pick two.