RedBullet
Založený: 02.12.2010
Príspevky: 7
Zaslal: 2010-12-02 14:52
Návrat hore
Odpovedať s citátom
|
In my database I am storing structured text as XML in a text field. Essentially it is WDDX that I have serialized.
I am wondering if there is a mechanism in phpMyEdit that lets me process that field appropriately.
I can certainly write my own PHP code to handle the serialization/deserialization easily, just not sure what hooks might exist in phpmyedit.
Thanks in advance!
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2010-12-02 17:19
Návrat hore
Odpovedať s citátom
|
See the documentation on using custom PHP scripts, and also Triggers.
http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.fields.php.html#AEN1201
http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.triggers.html
|
RedBullet
Založený: 02.12.2010
Príspevky: 7
Zaslal: 2010-12-02 18:50
Návrat hore
Odpovedať s citátom
|
Yea, I saw that.
So, for a text field that contains serialized data, would I write a php script to de-serialize and use the php opt, but then have to use an update trigger to serialize it back to the DB again?
Or am I not understanding it...
Thanks in advance!
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2010-12-02 18:55
Návrat hore
Odpovedať s citátom
|
I fail to grasp the objective. Experiment with triggers, or search the forum for keywords relevant to your objective.
|
RedBullet
Založený: 02.12.2010
Príspevky: 7
Zaslal: 2010-12-02 19:22
Návrat hore
Odpovedať s citátom
|
Oh don't give up on me yet! I think you are on the right track!
Basically I am storing some XML in a text field. The XML is essentially structured data for me. For example:
<ride>
<distance>
50 miles
</distance>
<terrain>
hilly
</terrain>
</ride>
And what I want to do is be able to format it when it is being rendered:
ride distance: 50 miles
ride terrain: hilly
Then when they edit the record I would display entry fields for those and then generate the XML to save in the field.
Does that make more sense?
|
doug
Založený: 10.02.2003
Príspevky: 1013
Bydlisko: Denver, Colorado (USA)
Zaslal: 2010-12-02 22:05
Návrat hore
Odpovedať s citátom
|
Design wise, it is a waste of time to store the markup code. Simply store data. Create the markup on-the-fly to surround the bits of data.
Use CONCAT to manipulate record display, and (?) a custom PHP script to create and write an XML file assuming the XML file gets an HTML document.
|
RedBullet
Založený: 02.12.2010
Príspevky: 7
Zaslal: 2010-12-02 22:17
Návrat hore
Odpovedať s citátom
|
The trick is that that field will actually contain an arbitrary number of rides. For example:
<event>
<ride> ... </ride>
<ride> ... </ride>
...
</event>
I have a hunch perhaps I am being too clever. It is nice to have this data in this particular field be flexible, but it might be more trouble that it is worth...
|
mainpart
Založený: 19.01.2013
Príspevky: 1
Zaslal: 2013-01-19 11:22
Návrat hore
Odpovedať s citátom
|
i've made success in this.
I'm handling custom serialized string via trigger on update and via php field on display
using
this
techique for unlimited fields creation i've created serialized field in mysql as longtext:
Kód: |
$opts['fdd']['serialized']=array(
'name'=>'Run',
'options'=>'C',
'php|C'=>'return.php',
); |
return.php in turn contains 4 fielded template with 3 inputs and 1 select as rude example. note that order of 1st-level items in serialized array is not preserved. there are much hardcoded in this example but this is a basic working idea.
Kód: |
<?
$var=$this->cgi['prefix']['data'].$this->fds[$k];
$data=unserialize($row['qf'.$k]);$num=0;
// output serialized data
if (is_array($data)) foreach ($data as $num1=>$value){
$num++;
echo "<div class=container>\r\n";
echo "<input name='".$var."[".$num."][1]' type=text value='".$value[1]."'>\r\n";
echo "<select name='".$var."[".$num."][2]'><option value=1 " . ($value[2]==1 ? "selected" : "") .">Text1</option><option value=2 " . ($value[2]==2 ? "selected" : "") .">Text2</option><option value=3 " . ($value[2]==3 ? "selected" : "") .">Text3</option></select>\r\n";
echo "<input name='".$var."[".$num."][3]' type=text value='".$value[3]."'>\r\n";
echo "<input name='".$var."[".$num."][4]' type=text value='".$value[4]."'>\r\n";
echo "<a href=# class=\"remove\">Remove</a>\r\n";
echo "</div>\r\n";
}
//output stub used for new fields
echo "<div class=container>\r\n";
echo "<input name='".$var."[0][1]' type=text>\r\n";
echo "<select name='".$var."[0][2]'><option value=1>Text1</option><option value=2>Text2</option><option value=3>Text3</option></select>\r\n";
echo "<input name='".$var."[0][3]' type=text>\r\n";
echo "<input name='".$var."[0][4]' type=text>\r\n";
echo "<a href=# class=".$var."_add>Add</a>\r\n";
echo "</div>\r\n"
?>
<script>
// this code used to handled multiplication of stub
$(document).ready(function(){
//add all remove actions
$('a.remove').click(function(){
$(this).closest('div').remove();
return false;
});
var newRowNum = <?=$num?>;
$('.<?=$var."_add"?>').click(function(){
newRowNum += 1;
var addRow = $(this).closest('div');
var newRow = addRow.clone();
console.log($('.container', newRow));
$(newRow).append('<a href="" class=remove>remove</a>');
$('.<?=$var."_add"?>',newRow).remove();
$('input, select', newRow).each(function(i){
console.log($(this));
$(this).attr('name',$(this).attr('name').replace('[0]','['+newRowNum+']') );
});
addRow.before(newRow);
$('a.remove', newRow).click(function(){
$(this).closest('div').remove();
return false;
});
return false;
});
});
</script>
<?
return '';
|
Here is the copy on
php fiddle
it's for 3 input and 1 select field.
Then we need to serialize it back when saved.
Kód: |
$opts['triggers']['update']['before']='xls_importer.TUB.inc'; |
Kód: |
<?
$name = $this->cgi['prefix']['data']."serialized";
unset($_POST[$name][0]);
$newvals['serialized']=serialize($_POST[$name]); |
|
victorpatrick
Založený: 30.05.2023
Príspevky: 35
Zaslal: 2023-09-19 05:36
Návrat hore
Odpovedať s citátom
|
To store the markup code is inefficient from a design standpoint. merely keeping the data. In order to frame the data chunks, quickly create the markup.
Use CONCAT to alter the display of records, and (?) a unique PHP script to generate and write an XML file, assuming the XML file receives an HTML document.
cookie clicker
|
slpo
Založený: 22.09.2023
Príspevky: 1
Zaslal: 2023-09-22 19:12
Návrat hore
Odpovedať s citátom
|
phpMyEdit is a popular PHP library for creating MySQL database interfaces. While it provides a lot of flexibility for generating and managing forms and tables, handling custom data types like serialized XML in a text field may require some customization. There isn't a built-in feature in phpMyEdit specifically designed for serialized XML data. To process such data appropriately, you can consider the following steps:
Custom Callbacks: In phpMyEdit, you can use custom callbacks to manipulate data during the display and update processes. Here's a general outline of how you might handle serialized XML data:
Display: In the display callback, you can unserialize the XML data and format it for presentation. You can define this callback using onDisplay.
Update: In the update callback, you can serialize the updated XML data before saving it to the database. You can define this callback using onUpdate.
Custom Input and Output Functions: You can define your own custom input and output functions for handling the XML data. These functions can be specified when you create your phpMyEdit instance using the input_funcs and output_funcs options.
Use PHP Functions: As you mentioned, you can always write your own PHP code to handle the serialization and deserialization of the XML data when you retrieve and update records. This gives you complete control over how the XML data is processed.
Here's a simplified example of how you might implement custom callbacks to handle serialized XML data:
php
Copy code
include('phpMyEdit.class.php');
// Define custom display callback
function displayXML($field, $value, $rowdata, $edit) {
return unserialize($value); // Deserialize the XML data
}
// Define custom update callback
function updateXML($field, $value, $rowdata, $edit) {
return serialize($value); // Serialize the updated XML data
}
$opts = array(
'dsn' => 'mysql://username:password@localhost/database',
'table' => 'your_table',
'fields' => '*', // Replace with your field names
'onDisplay' => array('field_name' => 'displayXML'), // Specify your display callback
'onUpdate' => array('field_name' => 'updateXML'), // Specify your update callback
);
$edit = new phpMyEdit($opts);
$edit->writePage();
In this example, replace 'field_name' with the actual name of the field storing the serialized XML data.
https://www.usaudiovisuals.pk/
By using custom callbacks or input/output functions, you can integrate your custom PHP code to handle the serialization and deserialization of XML data within phpMyEdit.
|
chicago0
Založený: 19.09.2022
Príspevky: 140
Zaslal: 2023-09-25 11:00
Návrat hore
Odpovedať s citátom
|
I adore that you informed me about this article since I think it's amazing. That is exactly what I was hoping to discover, and I sincerely hope you will continue to share such excellent stuff in the years to come.
wheel spinner
|
pigletgun
Založený: 06.07.2022
Príspevky: 6
Zaslal: 2023-10-03 09:11
Návrat hore
Odpovedať s citátom
|
The 2017 ICC Champions Trophy cricket event was commemorated by the Google Doodle Game
doodle cricket
.
|
dvbx yug
Založený: 03.09.2023
Príspevky: 88
Zaslal: 2023-11-20 11:47
Návrat hore
Odpovedať s citátom
|
When you use a genuine service, you will be able to provide instructions, share materials and choose the formatting style.
www.tianbianhardware.com/product-category/window-hinges/
|
seodon
Založený: 23.08.2023
Príspevky: 815
Zaslal: 2023-12-07 07:04
Návrat hore
Odpovedať s citátom
|
Seriously sturdy, magnificent, fact-filled information and facts listed here. A person's discussions Never need disappoint, and the unquestionably is valid listed here in addition. You actually continually make a fun learn. Do you convey to I'm just happy?: )#) Keep up to date the nice reports.
Kuliah gratis di Universitas Budi Luhur
|
muzammilseo978
Založený: 09.12.2023
Príspevky: 229
Zaslal: 2024-03-17 12:26
Návrat hore
Odpovedať s citátom
|
I felt very happy while reading this site. This was really very informative site for me. I really liked it. This was really a cordial post. Thanks a lot!.
CHIMNEY CARE
|
Odoslať novú tému
Odpovedať na tému
Choď na stránku 1, 2 Ďalší
|