News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Mod Authors: SMF 2.0 Database Functions

Started by SleePy, February 21, 2008, 05:57:21 PM

Previous topic - Next topic

Bl4ck.bt

yes he deleted all entries in the table

i tried {string:123}
no fatal error
but
at first save nothing happens, and at second save all the entries are deleted again


karlbenson

'123' => 'custom123_%_$i',
should be
'123' => 'custom123_%_' . $i,

Bl4ck.bt


Hiver101

#64
i'm not really a fluent with sql script, i want to know what function should is use to update the specific row?

onepiece

You should $smcFunc['db_query'] for UPDATE. Example.

$smcFunc['db_query']('', '
UPDATE {db_prefix}some_table
SET some_field = {int:some_parameter_1}
WHERE some_field = {int:some_parameter_2}',
array(
'some_parameter_1' => 1,
'some_paremeter_2' => 2,
)
);

Hiver101

Hi Tenma,
Thanks for the help. but i hope you can help me more on my modification. Here is my problem. I have this code added on my profile.template.php, I put there a textarea where user can edit their own css text to customize there own theme and this is already working and displaying the css text on my textarea, my problem now is how can is use the function that you pointed to update the css field on my members table with the value from textarea?

<textarea name="style" rows="30" cols="60">', $user_info['css'] ,'</textarea><input type="submit" action="SaveStyle" style="margin: 0 1ex 1ex 1ex;" value="Save Style" />

please help.

onepiece

In which profile area do you have that field added?

Hiver101


onepiece

Try this.

Sources/Profile-Modify.php

Code (Find) Select
// Free memory!

Code (Replace) Select
if (isset($_POST['style']))
updateMemberData($context['id_member'], array('css' => $smcFunc['htmlspecialchars']($_POST['style'], ENT_QUOTES)));

// Free memory!


'css' should be name of the field in the database.

Hiver101


onepiece

You're welcome. Glad that I could be of help.

Hiver101

Yes! and i will show you the result once I'm done.

Sudhakar Arjunan

Thanks for the useful db codes sleepy.

Now i have started learning to creating my own mod for SMF.
Working on New Mods & Themes for SMF... Will update soon... My Blog page
My Smf forum : Discuss ITAcumens :: My SMF Forum

OutofOrder

I know RC1-1 is still not the final release, and I know this is something that must have been considered already, given the quality that the SMF devs always look for this piece of software, so please take this question as a humble reminder :)
Will it be allowed for column creation with the UNSIGNED attribute? Currently RC1-1 can't handle it and it's not possible for a mod to be designed with this in mind. Also, if a table has to be created having columns that replicate columns from default SMF tables (i.e. id_member), the created columns won't be true replicas from the originals.

niko

Quote from: OutofOrder on June 12, 2009, 01:44:20 AM
I know RC1-1 is still not the final release, and I know this is something that must have been considered already, given the quality that the SMF devs always look for this piece of software, so please take this question as a humble reminder :)
Will it be allowed for column creation with the UNSIGNED attribute? Currently RC1-1 can't handle it and it's not possible for a mod to be designed with this in mind. Also, if a table has to be created having columns that replicate columns from default SMF tables (i.e. id_member), the created columns won't be true replicas from the originals.

RC2 will include support for unsigned columns.
Websites: Madjoki || (2 links retracted by team, links out of date and taken over.)
Mods: SMF Arcade, Related topics, SMF Project Tools, Post History

WIP Mods: Bittorrent Tracker || SMF Wiki

OutofOrder

@Arantor: as of RC1-1, $smcFunc['db_add_column'] nor $smcFunc['db_create_table'] have a working parameter to create new unsigned columns.

@Niko: that's great to know, thank you. :)

[SiNaN]

Quote from: Arantor on June 26, 2009, 07:39:36 PM
Oh, just noticed...
db_change_column isn't documented as far as I can see - there's a link but the link doesn't go anywhere.

Updated. Thanks!
Former SMF Core Developer | My Mods | SimplePortal

kaewjung


[SiNaN]

You can find many examples if you check a few mods in the Mod Site.
Former SMF Core Developer | My Mods | SimplePortal

Advertisement: