how add/update/delete data in MySQL database here?

P

PHP2

how add/update/delete data in MySQL database here?



CREATE TABLE IF NOT EXISTS example
(
item VARCHAR(255) NULL,
category VARCHAR(255) NULL,
picture LONGBLOB NULL,
model VARCHAR(255) NULL,
serial_number VARCHAR(255) NULL,
information TEXT NULL,
date_purchased DATE NULL,
depreciation DOUBLE NULL,
assigned_display DOUBLE NULL,
depreciation_life DOUBLE NULL,
remaining_life DOUBLE NULL,
cost DOUBLE NULL,
book_value DOUBLE NULL

) TYPE=MyISAM;



any help?
 
M

Malcolm Dew-Jones

PHP2 ([email protected]) wrote:
: how add/update/delete data in MySQL database here?



: CREATE TABLE IF NOT EXISTS example
: (
: item VARCHAR(255) NULL,
: category VARCHAR(255) NULL,
: picture LONGBLOB NULL,
: model VARCHAR(255) NULL,
: serial_number VARCHAR(255) NULL,
: information TEXT NULL,
: date_purchased DATE NULL,
: depreciation DOUBLE NULL,
: assigned_display DOUBLE NULL,
: depreciation_life DOUBLE NULL,
: remaining_life DOUBLE NULL,
: cost DOUBLE NULL,
: book_value DOUBLE NULL

: ) TYPE=MyISAM;


`DBI' - found on CPAN

You would also need the mysql DBD module

Once installed, type perldoc DBI for usage instructions.
 
G

gnari

PHP2 said:
how add/update/delete data in MySQL database here?



CREATE TABLE IF NOT EXISTS example
(
item VARCHAR(255) NULL,
category VARCHAR(255) NULL,

[snip more SQL]
any help?

INSERT INTO example ('foo','bar');

UPDATE example set information='none' WHERE item='foo';

DELETE FROM example WHERE cost>0;

gnari

P.S.: DBI can help
 
P

PHP2

I am totaly newbie in Perl.. can you write to me whole script?



gnari said:
PHP2 said:
how add/update/delete data in MySQL database here?



CREATE TABLE IF NOT EXISTS example
(
item VARCHAR(255) NULL,
category VARCHAR(255) NULL,

[snip more SQL]
any help?

INSERT INTO example ('foo','bar');

UPDATE example set information='none' WHERE item='foo';

DELETE FROM example WHERE cost>0;

gnari

P.S.: DBI can help
 
G

gnari

PHP2 said:
I am totaly newbie in Perl.. can you write to me whole script?

I do not use MySQL, but a script could contain bits like this:

use DBI;
my $dbh =
DBI->connect("dbi:mysql:database=$yourdatabasename",$username,$password);
$dbh->do("INSERT INTO example VALUES ('foo','bar')");
$dbh->do("INSERT INTO example VALUES (?,?)",'foo2','bar2');
$dbh->do("UPDATE example set information='none' WHERE item='foo'");
$dbh->do("DELETE FROM example WHERE cost>0");

gnari
 
P

PHP2

thanks

gnari said:
I do not use MySQL, but a script could contain bits like this:

use DBI;
my $dbh =
DBI->connect("dbi:mysql:database=$yourdatabasename",$username,$password);
$dbh->do("INSERT INTO example VALUES ('foo','bar')");
$dbh->do("INSERT INTO example VALUES (?,?)",'foo2','bar2');
$dbh->do("UPDATE example set information='none' WHERE item='foo'");
$dbh->do("DELETE FROM example WHERE cost>0");

gnari
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top