purplecat: Programming the Eniac Computer (programming)
[personal profile] purplecat
Can I ask what is the difference between the database tables userpicmap2 and userpicmap3 (and possibly userpicmap1 though I couldn't find that mentioned in the code on a quick grep). userpicmap3 seems to be the one most used and there are comments in the code that suggest userpicmap2 is just there for backwards compatibility. Is that correct?
purplecat: Hand Drawn picture of a Toy Cat (Default)
[personal profile] purplecat
Me again :/ Still on bug 2152.

I wanted to change some of the labels in the settings for display. I found these in en.dat, changed them, updated the database and everything was working fine. But, all of a sudden, any new changes I make in en.dat don't appear to be getting picked up - this includes resetting everything using patch -R and updating the database* - I'm still getting my new labels turning up rather than the old ones.

What might I have done? (I did have a play with the test suites following some discussion recently and [staff profile] denise (I think) mentioned these can corrupt the database in some way).

I'm using a dreamhack, in case that's relevant.

*stop-apache

$LJHOME/bin/upgrading/update-db.pl -r -p --innodb
$LJHOME/bin/upgrading/update-db.pl -r --cluster=all --innodb
$LJHOME/bin/upgrading/texttool.pl load

start-apache
tyggerjai: (Default)
[personal profile] tyggerjai
One of the fields in the db user table is set to only accept certain values. I need to add an acceptable value, preferably without dropping the entire table and rebuilding it. Any hints? There's probably an alter command....
anarres: (Default)
[personal profile] anarres
In Dreamwidth you can interact with the database using Perl's DBI module, but with a few Dreamwidth-specific methods layered on top. I've been trying to figure out how to write new rows to a database table. After looking at some other Dreamwidth scripts to see how it's done, I wrote the following script (which doesn't work):

# -------------------- ~/dw/bin/dev/test.pl ----------------------------
#!/usr/bin/perl

use lib "$ENV{LJHOME}/cgi-bin";
require 'ljlib.pl';
use strict;
use warnings;

my $cart = {
authcode => 'blahblahblahblah',
userid => 12,
cartid => 33,
};

my $dbh = LJ::get_db_writer() or return undef;

$dbh->do(
q{INSERT INTO payments (userid, cartid) VALUES ( ?, ?)},
$cart->{userid}, $cart->{cartid}
);

die "Database error: " . $dbh->errstr . "\n" if $dbh->err;
# ---------------------------------------------------------------------

The question marks are SQL placeholders, which prevent SQL injection attacks.

When I ran this I got the error: 'DBI::db=HASH(0x426eff0)->do(...): attribute parameter '12' is not a hash ref at test.pl line 22.'

It seemed to be complaining that $cart->{userid} is not a hash ref. I had no idea why it would want a hash ref there, but I bemusedly decided to give it what it wanted, and replaced

$cart->{userid}, $cart->{cartid}

with:

$cart, $cart

Running the script again gave an SQL error instead of a Perl error: 'Database error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 2'.

So it seems like giving it a hash ref is the right thing to do, but I'm giving it the wrong kind of hash ref. I'm completely confused: what's the right syntax for inserting a row into the database?
foxfirefey: A guy looking ridiculous by doing a fashionable posing with a mouse, slinging the cord over his shoulders. (geek)
[personal profile] foxfirefey
A while ago I made the starts of an article about exploring the database. It's not quite finished yet, but I figured I should post about it in case the beginning ended up being helpful to anybody who wanted to start poking around database related things on their dev enviroment.

Profile

dw_dev_training: The stylised 'd', with the word 'dev' above, and the word 'training' at the side, representing the dw_dev_training comm. (Default)
Dreamwidth Development Training

January 2017

S M T W T F S
1234567
891011121314
151617 18192021
22232425262728
293031    

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Aug. 21st, 2017 11:33 pm
Powered by Dreamwidth Studios