Jump to content

flash gordon

Members
  • Posts

    150
  • Joined

  • Last visited

    Never

Everything posted by flash gordon

  1. ok. I thought it was for 2 different things: regular sql and for stored procedures. Thanks for all the help. [RESOLVED]
  2. Looks like I'm going to have to do it on the php side, my SQL isn't good enough But how do I know that IF and CASE is ONLY for stored procedures. This link http://dev.mysql.com/doc/refman/5.0/en/if-statement.html doesn't seem to tell me that. Thanks for all the help.
  3. I'm trying to make a update or insert query. It's insert/updates 4 tables of data. However, not all tables must have data. So I could be updating some and inserting into others. but why would SELECT CASE WHEN (10>5) THEN (SELECT (5+1)) ELSE (SELECT (1+1)) END work and not the second one?
  4. everything seems to give me an error SELECT CASE WHEN (10>5) THEN (SELECT (5+1)) ELSE (SELECT (1+1)) END works but this gives an error CASE WHEN (10>5) THEN (SELECT (5+1)) ELSE (SELECT (1+1)) END
  5. that really is my whole query. I'm using MySQL Query Browser to test to get the syntax correct. Here's a screenshot. I'm not trying to make a stored procedure or anything, just a plain ol' query that's a conditional. [attachment deleted by admin]
  6. thank you for the reply. This is the doc page on "IF". http://dev.mysql.com/doc/refman/5.0/en/if-statement.html. How do you interpret that to mean IF(CONDITION, DO_WHEN_TRUE, DO_WHEN_FALSE)? Also, copying and pasting your code still gives me a syntax error. thanks again.
  7. IF (10 > 5) THEN SELECT * FROM contact_chat ELSE SELECT * FROM contact_phone END IF still an error
  8. IF TRUE THEN SELECT * FROM contact_chat; ELSE SELECT * FROM contact_phone; END IF still says there is an error
  9. Apparently I have a syntax error. Can anyone tell me what it is? IF TRUE THEN SELECT * FROM contact_chat ELSE SELECT * FROM contact_phone END IF MySQL Version: MySQL 5.0.75-0ubuntu10.2 via TCP/IP
  10. Thanks zeodragonzord! Yeah, that helps a lot. The main reason I'm was asking is not organization but expandability. I have 6 applications (and that number continues to grow) that all use the same authentication code. It seems most expandable to have the authentication in it's own encapsulated place with each application in its own as well. Thanks again, zeodragonzord.
  11. alrighty. thank you much for the help. cheers [RESOLVED]
  12. thank you. And even though this is deprecated, it's a good thing that the single quotes are automatically escaped? What's the replacement to the deprecated property?
  13. I'm trying to test out my security a bit and I've noticed that php is escaping my single quotes. For instance I enter x' OR 1=1-- in a form and the output it gives me is x\' OR 1=1--. Is there a setting in php or apache that automatically escapes single quotes? cheers.
  14. That PDO looks pretty nice! I was using ADO and not a big fan of it. I'll have to look into that one or zend sometime.
  15. I'm not a backend developer, just a good developer. I can't tell you the internals of the JDBC but the idea still remains that it's polymorphic and independent of the database and database specific syntax. Sorry I can't elaborate any further how Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); Connection conn = DriverManager.getConnection("jdbc:derby:COFFEES"); PreparedStatement updateSales = con.prepareStatement( "UPDATE COFFEES SET SALES = ? WHERE COF_NAME LIKE ? "); updateSales.setInt(1, 75); updateSales.setString(2, "Colombian"); updateSales.executeUpdate(): runs. Perhaps it deals with the database drivers that JDBC uses as a proxy, but I have no clue about the java internals, jut the theory.
  16. I just posted this a minute ago, but java's JDBC is completely awesome as an database abstraction layer. http://java.sun.com/docs/books/tutorial/jdbc/basics/retrieving.html The record sets and execute statements are pretty nice.
  17. In my opinion, you should strive for database classes as an abstraction to the actual connectivity dependencies. For instance, mySQL uses different syntax that Oracle. So you're database abstraction layer would look something like $db = new MySQLLayer(); // or new Orcale // etc all polymorphic of each other $recordSet = $db->executeStatment($statement); so if you're database change all you have to do if factory in a new Abstraction Layer 1 place in your code! and all the API calls stay the same. Java's JDB is great with this. You might want to look into it a bit. It will blow your mind once you understand it. http://java.sun.com/docs/books/tutorial/jdbc/basics/retrieving.html
  18. I'll give my scenario then ask a couple of questions. I have system which requires users to login (authentication). Once logged in, a user can manage a project by creating, modifying, assigning, attaching files or notes, etc to project. The authentication part could also used by another system such as billing. I have 2 (or more) application that can all benefit from 1 authentication system. How do I split up the databases? Do I have database for authentication which would have tables users, groups, etc. And then another database for just the "System A" which would have tables like projects, specs, etc. And then another for billing? Or should all of these fall under 1 databases because they all use authentication? Here's the thing I think is a bit weird. The applications and databases are nearly independent of each other. The only exception is my SystemA.notes table has references to "user ids" which would be in the Authentication.users table. The id would be a foreign key to not just a table but a database. Is this typical? What should be my structure? thanks for the help. cheers
  19. Okay, so the docs say define() defines a constant value in php but it is also global as well? How does that define method work? I specifically asking for stuff like define("AMFPHP_BASE", realpath(dirname(dirname(dirname(__FILE__)))) . "/"); require_once(AMFPHP_BASE . "shared/app/BasicGateway.php"); require_once(AMFPHP_BASE . "shared/util/MessageBody.php"); but now other class don't define() AMFPHP_BASE but are able to have access to the constant. how it is typically used?
  20. Thanks for the input. I'm kind of leaning that way too because if the DB user and pass changes, I'd have to go into all the utils and change the request for the connection as well, which I don't want to do. cheers
  21. I'm programming in an OO mannor. I have several util, factory, and DAO classes. My question is, who should be creating the database connection? Should the connection get aggregated into the static method or should the method create its own connection. Consider the following example: class TemplateUtil { // Method creates its own connection and logic is fully encapsulated public static function convertSiteNameToID($name) { $name = strtoupper(trim($name)); $conn = ADOConnectionUtil::createDefaultConnection("flashfac_templates"); $sql = "SELECT id FROM templates WHERE name = '$name'"; $row = $conn->GetRow($sql); $id = $row["id"]; return $id; } // Method needs a connection passed into it and relies on the context to // do so....perhaps this makes less connections and more control who connects when. public static function convertSiteNameToID($conn, $name) { $name = strtoupper(trim($name)); $sql = "SELECT id FROM templates WHERE name = '$name'"; $row = $conn->GetRow($sql); $id = $row["id"]; return $id; } } I don't have enough experience with php to know what is the better of the options. Any ideas? Thanks guys!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.