Wordpress - add featured post with image using MySQL - mysql

I am trying to add featured post with image in Wordpress using MySQL. I want to do it only by MySQL(no php, only SQL). I tried to add post and then I added meta for the post too. Still, I cannot see featured post with image. Please advise where I am wrong? I have generated XML for records, please check and let me know where I am wrong.
Post Data:
<?xml version="1.0" encoding="utf-8"?>
<table_data name="wp_posts">
<row>
<field name="ID">62</field>
<field name="post_author">1</field>
<field name="post_date">2018-04-24 00:00:00</field>
<field name="post_date_gmt">2018-04-24 00:00:00</field>
<field name="post_content"><img class="alignnone size-medium wp-image-26" src="http://test.com/wp-content/uploads/2018/photos/testing2.jpg" alt="test" width="300" height="219"></field>
<field name="post_title">Manual post</field>
<field name="post_excerpt"></field>
<field name="post_status">publish</field>
<field name="comment_status">open</field>
<field name="ping_status">open</field>
<field name="post_password"></field>
<field name="post_name"></field>
<field name="to_ping"></field>
<field name="pinged"></field>
<field name="post_modified">0000-00-00 00:00:00</field>
<field name="post_modified_gmt">0000-00-00 00:00:00</field>
<field name="post_content_filtered"></field>
<field name="post_parent">0</field>
<field name="guid"></field>
<field name="menu_order">0</field>
<field name="post_type">post</field>
<field name="post_mime_type"></field>
<field name="comment_count">0</field>
</row>
<row>
<field name="ID">63</field>
<field name="post_author">1</field>
<field name="post_date">2018-04-24 00:00:00</field>
<field name="post_date_gmt">2018-04-24 00:00:00</field>
<field name="post_content"></field>
<field name="post_title">testing2</field>
<field name="post_excerpt"></field>
<field name="post_status">inherit</field>
<field name="comment_status">closed</field>
<field name="ping_status">open</field>
<field name="post_password"></field>
<field name="post_name">testing2</field>
<field name="to_ping"></field>
<field name="pinged"></field>
<field name="post_modified">0000-00-00 00:00:00</field>
<field name="post_modified_gmt">0000-00-00 00:00:00</field>
<field name="post_content_filtered"></field>
<field name="post_parent">62</field>
<field name="guid">http://test.com/wp-content/uploads/2018/photos/testing2.jpg</field>
<field name="menu_order">0</field>
<field name="post_type">attachment</field>
<field name="post_mime_type">image/jpeg</field>
<field name="comment_count">0</field>
</row>
</table_data>
Meta of Post
<table_data name="wp_postmeta">
<row>
<field name="meta_id">211</field>
<field name="post_id">62</field>
<field name="meta_key">_thumbnail_id</field>
<field name="meta_value">63</field>
</row>
</table_data>
What is missing and how to add using MySQL?
Thanks

Related

Hide string name from field in odoo 12

When you define a field in odoo, by default, it displays the string for that value and next to it, the value.
If you don't put the field between group tags, the string value, doesn't appear.
The problem is that I am defining a tree view which doesn't contain group tags:
<record model="ir.ui.view" id="field_partida_fertilizer_tree">
<field name="name">field.diary.partida.fertilizer.tree.view</field>
<field name="model">field.diary.partida.fertilizer</field>
<field name="priority" eval="17"/>
<field name="arch" type="xml">
<tree string="Fertilizante">
<field string= 'Nombre' name="fertilizer"/>
<field string='N' name="nitrato" options='{"show_string": False}' widget="percentpie"/>
<field string='P' name="fosforo" options='{"fg_color": "white"}' widget="percentpie"/>
<field string='K' name="potasio" options='{"fg_color": "white"}' widget="percentpie"/>
<field string='Cantidad (kg)' name="quantity"/>
</tree>
</field>
</record>
By using widget percentpie, I can display this:
I want to hide the letter N next to the graph but not the column and I can't find any property of the widget to do that. The only way I could trick this is by giving the color white to the text so it disappears with the background, but the column cant be centered.
I have tried with the option show_string I found on GitHub but it doesn't work.
Any help would be awesome...
Thank you!
Odoo defines a condition in the PercentPie template to show the string attribute vaue:
<span t-if="widget.string"><t t-esc="widget.string"/></span>
You can alter the template and define a new condition base on a value (show_string ) passed through the options attribute:
<?xml version="1.0" encoding="UTF-8"?>
<templates id="template" xml:space="preserve">
<t t-extend="FieldPercentPie">
<t t-jquery="span" t-operation="attributes">
<attribute name="t-if">widget.string and (widget.attrs.options.show_string === undefined or widget.attrs.options.show_string)</attribute>
</t>
</t>
</templates>
Create a new XML file with the above content and add it under the qweb section of the manifest file.
Example:
<record model="ir.ui.view" id="field_partida_fertilizer_tree">
<field name="name">field.diary.partida.fertilizer.tree.view</field>
<field name="model">field.diary.partida.fertilizer</field>
<field name="priority" eval="17"/>
<field name="arch" type="xml">
<tree string="Fertilizante">
<field string='Nombre' name="fertilizer"/>
<field name="nitrato" options='{"show_string": False}' widget="percentpie"/>
<field name="fosforo" options='{"show_string": False}' widget="percentpie"/>
<field name="potasio" options='{"show_string": False}' widget="percentpie"/>
<field string='Cantidad (kg)' name="quantity"/>
</tree>
</field>

XPATH _ Extract values XML

How Can I extract the characteristics values for the following XML code using XPATH?
Example: Extract displayName, firsName, lastName, etc.
This is my XML data:
<directory>
<fieldset>
<field id="displayName">Display name</field>
<field id="firstName">First name</field>
<field id="lastName">Last name</field>
<field id="preferredName">Preferred name</field>
<field id="jobTitle">Job title</field>
<field id="workPhone">Work Phone</field>
<field id="canUploadPhoto">Can Upload Photo</field>
</fieldset>
<employees>
<employee id="229">
<field id="displayName">Susan</field>
<field id="firstName">TestName</field>
<field id="canUploadPhoto">no</field>
</employee>
</employees>
</directory>
You can get actual values along the following XPath expression:
/directory/employees/employee/field[#id="displayName"]/text()

error programming when using inherit in oodo9

i am new in oodo9, i have got error when i have try to add a new field into res.partner using inherit, it tell me that the new field does not exist in res.partner, please help me
class testtt(models.Model):
_inherit ='res.partner'
_columns = {
'test_field': fields.char('test field'),
}
testtt()
<record id="testtt" model="ir.ui.view">
<field name="name"> test.form </field>
<field name="model">res.partner</field>
<field name="inherit_id" ref="base.view_partner_form" />
<field name="arch" type="xml">
<field name="name" position="after">
<field name="test_field" />
</field>
</field>
</record>

Multiple indexes in Solr

I want to index two tables from MySQL using Apache Solr. Please see my data-config and schema files below.
<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/test" user="root" password="root" batchSize="1" />
<document name="tb_location">
<entity name="tb_location" query="SELECT * FROM tb_location">
<field column="loc_code" name="id"/>
<field column="loc_code" name="loc_code"/>
<field column="loc_name" name="loc_name"/>
<field column="loc_name" name="loc_name_ci"/>
<field column="ADM1_FULL_NAME" name="state"/>
</entity>
</document>
<document name="person">
<entity name="person" query="SELECT * FROM person">
<field column="id" name="personid"/>
<field column="fname" name="fname"/>
<field column="lname" name="lname"/>
<field column="town" name="town"/>
</entity>
</document>
</dataConfig>
Schema.xml
<field name="id" type="string" indexed="true" stored="true" required="true" multiValued="false" /> -
<field name="loc_code" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="loc_name" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="loc_name_ci" type="string_ci" indexed="true" stored="true" required="true" multiValued="false" />
<field name="state" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="personid" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="fname" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="lname" type="string" indexed="true" stored="true" required="true" multiValued="false" />
<field name="town" type="string" indexed="true" stored="true" required="true" multiValued="false" />
Also i created unique id for each tables (id and personid). But when i execute the dataimport module, nothing is fetched or indexed. Can someone help me to figure out where exactly the problem ?
Please check the below link for Multiple indexes...
Multiple indexes
Fixed it !!! data-config.xml should be as follows.
<dataConfig>
<dataSource type="JdbcDataSource" driver="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost:3306/test" user="root" password="root" batchSize="1" />
<document name="tb_location">
<entity name="tb_location" query="SELECT * FROM tb_location">
<field column="loc_code" name="id"/>
<field column="loc_code" name="loc_code"/>
<field column="loc_name" name="loc_name"/>
<field column="loc_name" name="loc_name_ci"/>
<field column="ADM1_FULL_NAME" name="state"/>
</entity>
<entity name="person" query="SELECT * FROM person">
<field column="id" name="personid"/>
<field column="fname" name="fname"/>
<field column="lname" name="lname"/>
<field column="town" name="town"/>
</entity>
</document>
</dataConfig>

Whys is my MySQL query returning rows, but no values?

I'm using this query:
LOAD XML LOCAL INFILE '\\MC_Library_Video.xml' INTO TABLE video ROWS IDENTIFIED BY '<Item>';
On this XML file (abbreviated)
<Item>
<field name="Filename">V:\13 Assassins\13 Assassins.mkv</field>
<field name="Name">13 Assassins</field>
<field name="File Type">mkv</field>
<field name="Genre">Adventure; Drama; Foreign; Martial Arts</field>
<field name="Date">40662</field>
<field name="Bitrate">7501</field>
<field name="Image File">13 Assassins.jpg</field>
<field name="Media Type">Video</field>
<field name="File Size">7041096346</field>
<field name="Duration">7509</field>
<field name="Date Created">1322620528</field>
<field name="Date Modified">1322620528</field>
<field name="Date Imported">1348075046</field>
<field name="Keywords">...</field>
<field name="Description">...</field>
<field name="Media Sub Type">Movie</field>
<field name="Sample Rate">48000</field>
<field name="Channels">6</field>
<field name="Bit Depth">16</field>
<field name="Compression">mkv video (video: AVC1, audio: DTS Audio)</field>
<field name="Width">1280</field>
<field name="Height">528</field>
<field name="MPAA Rating">R</field>
<field name="Director">Takashi Miike</field>
<field name="Actors">...</field>
<field name="Gross Revenue">$17,054,213</field>
<field name="Budget">$6,000,000</field>
<field name="FPS">23.9760400000000012</field>
<field name="Genres">Adventure; Drama; Foreign; Martial Arts</field>
</Item>
And I'm getting this result:
285 row(s) affected Records: 285 Deleted: 0 Skipped: 0 Warnings: 0
But when I look at the data for the table (SELECT * FROM media.video;) I get nothing. There's no data there. Am I missing something? The result makes it appear as if the data was read in, but the table is still blank.