Difference between revisions of "LSModule:MySQL"

From Lavish Software Wiki
Jump to navigation Jump to search
 
Line 5: Line 5:
 
* [[LSModule:MySQL:mysql (Object Type)|mysql]]
 
* [[LSModule:MySQL:mysql (Object Type)|mysql]]
 
* [[LSModule:MySQL:mysqlresult (Object Type)|mysqlresult]]
 
* [[LSModule:MySQL:mysqlresult (Object Type)|mysqlresult]]
 +
 +
== Example Usage ==
 +
function main()
 +
{
 +
    variable mysql DB
 +
    variable mysqlresult Result
 +
 +
/*
 +
  * Connect to db on localhost
 +
  * user/pass: jimmy/jimmys password
 +
  * DB name: db_562
 +
*/
 +
    if !${DB:Connect[localhost,jimmy,jimmys password,db_562](exists)}
 +
    {
 +
      echo Could not connect to MySQL database
 +
      return
 +
    }
 +
   
 +
/*
 +
  * SELECT user_id,user_name,user_email FROM table_users
 +
  * Place result in Result object
 +
*/
 +
  if !${DB:Query["SELECT user_id,user_name,user_email FROM table_users",Result](exists)}
 +
  {
 +
      echo Query failed
 +
      return
 +
  }
 +
 +
  while ${Result:FetchRow}
 +
  {
 +
      echo User ${Result.GetString[user_id]}: ${Result.GetString[user_name]}
 +
      echo -- Email Address: ${Result.GetString[user_email]}
 +
  }   
 +
}
  
 
== Downloads ==
 
== Downloads ==
 
=== Ready to Install ===
 
=== Ready to Install ===
 
* [http://www.lavishsoft.com/downloads/modules/LSMMySQL-20060515.zip LSMMySQL-20060515.zip]
 
* [http://www.lavishsoft.com/downloads/modules/LSMMySQL-20060515.zip LSMMySQL-20060515.zip]
: Compiled with LSModule v16
+
: Compiled with LSModule v16.  Install MySQL.dll to the LavishScript Modules folder, and libMySQL.dll to the Windows System32 folder.
  
 
=== Source Code ===
 
=== Source Code ===

Revision as of 21:43, 15 May 2006

Overview

This open-source module provides support for MySQL database interaction

Object Types

Example Usage

function main()
{
   variable mysql DB
   variable mysqlresult Result

/*
 * Connect to db on localhost
 * user/pass: jimmy/jimmys password
 * DB name: db_562
*/
   if !${DB:Connect[localhost,jimmy,jimmys password,db_562](exists)}
   {
      echo Could not connect to MySQL database
      return
   }
   
/*
 * SELECT user_id,user_name,user_email FROM table_users
 * Place result in Result object
*/
  if !${DB:Query["SELECT user_id,user_name,user_email FROM table_users",Result](exists)}
  {
     echo Query failed
     return
  }

  while ${Result:FetchRow}
  {
     echo User ${Result.GetString[user_id]}: ${Result.GetString[user_name]}
     echo -- Email Address: ${Result.GetString[user_email]}
  }    
}

Downloads

Ready to Install

Compiled with LSModule v16. Install MySQL.dll to the LavishScript Modules folder, and libMySQL.dll to the Windows System32 folder.

Source Code

See Also