问:
Wpf: How to color portion of a rectangle based on percentage?
I need to split a rectangle and color the various portions based on percentage, I've looked around and found some solutions but I can't understand which one is the best option for what I need. I post here an image showing what I need.

please can anyone point me in the right direction? Thanks

答:
You could for example fill a Grid with Border elements:

```<code><Grid>
    <Grid.Resources>
        <Style TargetType="Border">
            <Setter Property="BorderThickness" Value="2 2 2 0" />
            <Setter Property="BorderBrush" Value="Black" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
        </Style>
    </Grid.Resources>
    <Grid.RowDefinitions>
        <RowDefinition Height="20*" />
        <RowDefinition Height="10*" />
        <RowDefinition Height="25*" />
        <RowDefinition Height="50*" />
    </Grid.RowDefinitions>
    <Border Background="Red" />
    <Border Background="Yellow" Grid.Row="1" />
    <Border Background="Green" Grid.Row="2" />
    <Border Background="Blue" Grid.Row="3" BorderThickness="2" />
</Grid>
</code>```

Body:
You could for example fill a Grid with Border elements:

<Grid>
    <Grid.Resources>
        <Style TargetType="Border">
            <Setter Property="BorderThickness" Value="2 2 2 0" />
            <Setter Property="BorderBrush" Value="Black" />
            <Setter Property="SnapsToDevicePixels" Value="True" />
        </Style>
    </Grid.Resources>
    <Grid.RowDefinitions>
        <RowDefinition Height="20*" />
        <RowDefinition Height="10*" />
        <RowDefinition Height="25*" />
        <RowDefinition Height="50*" />
    </Grid.RowDefinitions>
    <Border Background="Red" />
    <Border Background="Yellow" Grid.Row="1" />
    <Border Background="Green" Grid.Row="2" />
    <Border Background="Blue" Grid.Row="3" BorderThickness="2" />
</Grid>


来源: stackexchange

问:
position:sticky in div tables
Is it possible to obtain the position: sticky effect on an HTML table build up using just divs and css?

Apparently if I try to add the position: sticky rule to the header,  which already contains the display: table-header-group rule, the sticky effects is null.

HTML

```<code><div class="container">
    <div class="header-row">
        <div class="header>Header</div>
        [...]
    </div>
    <div class="body-row">
        <div class="body>Content</div>
        [...]
    </div>
</div>
</code>```

CSS

```<code>.container {
  display: table;
}

.header-row {
  display: table-header-group;
  position: sticky;
  top: 0;
}

.body-row {
  display: table-row;
}

.body, .header {
  display: table-cell;
}
</code>```

Live fiddle: https://jsfiddle.net/Lc0rE/9fxobxb0/1/

答:
This question may be a few years old, but I came across the same issue. Especially now that position: sticky is a widely adopted positioning element now.

I got round this by adding a float to the Table header & Table Rows.

```<code>.header-row {
  display: table-header-group;
  position: sticky;
  top: 0;
  float: left;
}

.body-row {
  display: table-row;
  float: left;
}
</code>```

https://jsfiddle.net/58zes8rr/

There may be a cleaner option for this using Flexbox (Arguably not widely supported yet).

ContentLicense: CC BY-SA 3.0

Title: position:sticky in div tables

Body:
Is it possible to obtain the position: sticky effect on an HTML table build up using just divs and css?

Apparently if I try to add the position: sticky rule to the header,  which already contains the display: table-header-group rule, the sticky effects is null.

HTML

Header

        [...]

Content

        [...]

CSS

.container {
  display: table;
}

.header-row {
  display: table-header-group;
  position: sticky;
  top: 0;
}

.body-row {
  display: table-row;
}

.body, .header {
  display: table-cell;
}

Live fiddle: https://jsfiddle.net/Lc0rE/9fxobxb0/1/

Body:
This question may be a few years old, but I came across the same issue. Especially now that position: sticky is a widely adopted positioning element now.

I got round this by adding a float to the Table header & Table Rows.

.header-row {
  display: table-header-group;
  position: sticky;
  top: 0;
  float: left;
}

.body-row {
  display: table-row;
  float: left;
}

https://jsfiddle.net/58zes8rr/

There may be a cleaner option for this using Flexbox (Arguably not widely supported yet).


问:
Vue.js: Duplicated CSS class(CSS Component) is defined when import the same css file
I'm building an App with Vue.js and CSS Components. There are some Vue components, which share common styling.

Hello.vue:

```<code><template>
  <div :class="$style.title">Hello, World</div>
</template>
<script>
export default {}
</script>
<style module src="./common.css"></style>
</code>```

GoodBye.vue:

```<code><template>
  <div :class="$style.title">Goodbye, cruel world.</div>
</template>
<script>
export default {}
</script>
<style module src="./common.css"></style>
</code>```

common.css:

```<code>.title {
  font-weight: bold;
}
</code>```

When I compile and run this code, there are a duplicated CSS class(._2miFMUAEBLdLB9wHpgrYF2):

Screenshot: Duplicated CSS classes

How can I fix this duplication?

Complete code is available here: https://github.com/ryo-utsunomiya/css-modules-common-style

答:
I was just digging into this last night! I'm still working on understanding the best approaches but I'll share what I've discovered so far.

What you have will output the same css twice in dev mode, but in production it is deduped thanks to this in the webpack.prod.conf.js file.

```<code>new OptimizeCSSPlugin({
  cssProcessorOptions: config.build.productionSourceMap
  ? { safe: true, map: { inline: false } }
  : { safe: true }
}),
</code>```

However, this still adds duplicate hashes to your app.js to map the real class name to the module class name which can bloat up quick. This is true even if you name it.

The approach I'm leaning towards for now is just having a common stylesheet included in the root component with a simple non-scoped non-module style and the component will just have its own unique styles in it with module. You would just use the plain class names from common.

However, another approach I'm considering is doing this in my root component:

```<code><style module="$commonStyles" src="./common.css"></style>
</code>```

Then  making this.$commonStyles available throughout the app.

I'll let you know where I end up.

Body:
I'm building an App with Vue.js and CSS Components. There are some Vue components, which share common styling.

Hello.vue:

<template>

Hello, World

</template>

GoodBye.vue:

<template>

Goodbye, cruel world.

</template>

common.css:

.title {
  font-weight: bold;
}

When I compile and run this code, there are a duplicated CSS class(._2miFMUAEBLdLB9wHpgrYF2):

Screenshot: Duplicated CSS classes

How can I fix this duplication?

Complete code is available here: https://github.com/ryo-utsunomiya/css-modules-common-style

Body:
I was just digging into this last night! I'm still working on understanding the best approaches but I'll share what I've discovered so far.

What you have will output the same css twice in dev mode, but in production it is deduped thanks to this in the webpack.prod.conf.js file.

new OptimizeCSSPlugin({
  cssProcessorOptions: config.build.productionSourceMap
  ? { safe: true, map: { inline: false } }
  : { safe: true }
}),

However, this still adds duplicate hashes to your app.js to map the real class name to the module class name which can bloat up quick. This is true even if you name it.

The approach I'm leaning towards for now is just having a common stylesheet included in the root component with a simple non-scoped non-module style and the component will just have its own unique styles in it with module. You would just use the plain class names from common.

However, another approach I'm considering is doing this in my root component:

<style module="$commonStyles" src="./common.css"></style>

Then  making this.$commonStyles available throughout the app.

I'll let you know where I end up.


问:
Visual Studio Code doesn't format C# code
I created a new file, set the C# language, and wrote some code. Then I pressed Ctrl + Shift + F (or F1 → Format Document). And got I the error

Sorry, but there is no formatter for 'csharp'-files installed.

Also, I installed C# Extension, but it didn't help.
The Visual Studio Code version is 1.18.0.

答:
The C# extension powered by Omnisharp doesn't have a formatter included (as far as I know).

You can install C# FixFormat. That does the trick for me, but the formatting is not as good as in Visual Studio IDE.

ContentLicense: CC BY-SA 4.0


问:
FosUserBundle Registration, which saves data into 2 different tables
I am using FOSUserbundle in symfony 3 and want to use a second table,
where I save the address data.

Therefore I use the extended User Entity and the addresses Entity.

Workflow:

f.e. first_name,last_name,company and all other Formdata should go to md_user table.

copy of first_name,last_name,company etc should go to md_addresses table, which has got the "customer_id" field of md_user.id

To get it working I use the Eventlistener in RegistrationType:

```<code>->addEventListener(FormEvents::POST_SUBMIT, array($this, 'onPreSetData'));
</code>```

and the method:

```<code> public function onPreSetData(FormEvent $event)
{
    $user = $event->getData();
    $user->addAddress(new Addresses());
    $event->setData($user);

}
</code>```

Before I use $event->setData($user) in RegistrationType, the $user looks like:

My Questions are:

1) How to get the back the field id of md_user from doctrine

2) How to save the other data with this id to md_addresses

Thats what I have done right now.

User Entity:

```<code>namespace AppBundle\Entity;

 class User extends BaseUser
{

   /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * Different Logins for One Customer
     * @ORM\Column(name="customer_id",type="integer",nullable=true,options={"default":null})
     * @ORM\OneToMany(targetEntity="Addresses", mappedBy="user", cascade={"persist","remove"})
     **/
    protected $customer_id;

    /**
      * @var \DateTime
      * @ORM\Column(name="created", type="datetime")
      */
     protected $created;

     /**
      * @ORM\Column(name="mandant",type="integer")
      */
    protected $mandant;

     /**
      * @var string
      * @ORM\Column(name="salutation", type="string", length=1)
      */
     protected $salutation;

     /**
      * @var string
      * @ORM\Column(name="first_name", type="string", length=120)
      * @Assert\Length(
      *     min=2,
      *     max=120,
      *     minMessage="The name is too short.",
      *     maxMessage="The name is too long.",
      *     groups={"Registration", "Profile"}
      * )
      */
     protected $first_name;

     /**
      * @var string
      * @ORM\Column(name="last_name", type="string", length=255)
      * @Assert\Length(
      *     min=2,
      *     max=255,
      *     minMessage="The name is too short.",
      *     maxMessage="The name is too long.",
      *     groups={"Registration", "Profile"}
      * )
      */
     protected $last_name;

     /**
      * @var string
      * @ORM\Column(name="company", type="string", length=255)
      */
     protected $company;

     /**
      * @var string
      * @ORM\Column(type="string", type="string", length=150)
      */
     protected $street;

     /**
      * @var string
      * @ORM\Column(type="string", type="string", length=30)
      */
     protected $street_number;

     /**
      * @var string
      * @ORM\Column(type="string", type="string", length=150)
      */
     protected $city;

     /**
      * @var string
      * @ORM\Column(type="string", type="string", length=150)
      */
     protected $plz;

     /**
      * @var string
      * @ORM\Column(name="ustid", type="string", length=30)
      */
     protected $ustid;

     /**
      * @var string
      * @ORM\Column(name="country", type="string", length=6)
      */
     protected $country;

     /**
      * @ORM\Column(name="telephone",type="string",length=120)
      */
     protected $telephone;

     /**
      * @ORM\Column(name="email_info", type="string",length=255,nullable=true)
      */
     protected $email_info;
     /**
      * @ORM\Column(name="email_invoice", type="string",length=255,nullable=true)
      */
     protected $email_invoice;

     /**
      * @ORM\Column(name="send_info", type="boolean",nullable=true)
      */
     protected $send_info = true;

     /**
      * @ORM\Column(name="invoice_pdf", type="boolean",nullable=true)
      */
     protected $invoice_pdf = true;

     /**
      * @ORM\OneToMany(targetEntity="AppBundle\Entity\Addresses", mappedBy="customer_id", cascade={"persist","remove"})
      */
     protected $addresses;
     /**
      * @var bool
      * @ORM\Column(name="newsletter", type="boolean")
      */
     protected $newsletter=true;

     public function __construct()
     {
         parent::__construct();
         $this->created         = new \DateTime();
//         $this->addresses              = new ArrayCollection();
     }

     /**
      * @return mixed
      */
     public function getEmailInfo()
     {
         return $this->email_info;
     }

     public function setEmailInfo($email_info)
     {
         $this->email_info = is_null($email_info) ? $this->email : $email_info;
         return $this;
     }

     public function getEmailInvoice()
     {
         return $this->email_invoice;
     }

     /**
      * @param mixed $email_invoice
      * @return User
      */
     public function setEmailInvoice($email_invoice)
     {
         $this->email_invoice = is_null($email_invoice) ? $this->email : $email_invoice;
         return $this;
     }

     /**
      * @return mixed
      */
     public function getInvoicePdf()
     {
         return $this->invoice_pdf;
     }

     /**
      * @param mixed $invoice_pdf
      * @return User
      */
     public function setInvoicePdf($invoice_pdf)
     {
         $this->invoice_pdf = $invoice_pdf;
         return $this;
     }

     /**
      * @return mixed
      */
     public function getSendInfo()
     {
         return $this->send_info;
     }

     /**
      * @param mixed $send_info
      * @return User
      */
     public function setSendInfo($send_info)
     {
         $this->send_info = $send_info;
         return $this;
     }

     public function getTelephone()
     {
         return $this->telephone;
     }

     /**
      * @param mixed $telephone
      * @return User
      */
     public function setTelephone($telephone)
     {
         $this->telephone = $telephone;
         return $this;
     }

     public function setEmail($email)
     {
         $email = is_null($email) ? '' : $email;
         parent::setEmail($email);
         $this->setUsername($email);
         return $this;
     }

     /**
      * @return string
      */
     public function getSalutation()
     {
         return $this->salutation;
     }

     /**
      * @param string $saluation
      * @return User
      */
     public function setSalutation($salutation)
     {
         $this->salutation = $salutation;
         return $this;
     }

     /**
      * @return string
      */
     public function getFirstName()
     {
         return $this->first_name;
     }

     /**
      * @param string $first_name
      * @return User
      */
     public function setFirstName($first_name)
     {

         $this->first_name = $first_name;
         return $this;
     }

     /**
      * @return string
      */
     public function getLastName()
     {
         return $this->last_name;
     }

     /**
      * @param string $last_name
      * @return User
      */
     public function setLastName($last_name)
     {
         $this->last_name = $last_name;
         return $this;
     }

     /**
      * @return string
      */
     public function getCompany()
     {
         return $this->company;
     }

     /**
      * @param string $company
      * @return User
      */
     public function setCompany($company)
     {
         $this->company = $company;
         return $this;
     }

     /**
      * @return string
      */
     public function getUstid()
     {
         return $this->ustid;
     }

     /**
      * @param string $ustid
      * @return User
      */
     public function setUstid($ustid)
     {
         $this->ustid = $ustid;
         return $this;
     }

     public function getName()
     {
         return 'user';
     }

     /**
      * @return mixed
      */
     public function getMandant()
     {
         return $this->mandant;
     }

     /**
      * @param mixed $mandant
      * @return User
      */
     public function setMandant($mandant)
     {
         $this->mandant = $mandant;
         return $this;
     }

     /**
      * @return string
      */
     public function getCity()
     {
         return $this->city;
     }

     /**
      * @param string $city
      * @return User
      */
     public function setCity($city)
     {
         $this->city = $city;
         return $this;
     }

     /**
      * @return string
      */
     public function getCountry()
     {
         return $this->country;
     }

     /**
      * @param string $country
      * @return User
      */
     public function setCountry($country)
     {
         $this->country = $country;
         return $this;
     }

     /**
      * @return string
      */
     public function getStreet()
     {
         return $this->street;
     }

     /**
      * @param string $street
      * @return User
      */
     public function setStreet($street)
     {
         $this->street = $street;
         return $this;
     }

     /**
      * @return string
      */
     public function getStreetNumber()
     {
         return $this->street_number;
     }

     /**
      * @param string $street_number
      * @return User
      */
     public function setStreetNumber($street_number)
     {
         $this->street_number = $street_number;
         return $this;
     }

     /**
      * @return string
      */
     public function getPlz()
     {
         return $this->plz;
     }

     /**
      * @param string $plz
      * @return User
      */
     public function setPlz($plz)
     {
         $this->plz = $plz;
         return $this;
     }

     /**
      * Set created
      *
      * @param \DateTime $created
      *
      * @return User
      */
     public function setCreated($created)
     {
         $this->created = $created;

         return $this;
     }

     /**
      * Get created
      *
      * @return \DateTime
      */
     public function getCreated()
     {
         return $this->created;
     }

     /**
      * @return mixed
      */
     public function getCustomerId()
     {
         return $this->customer_id;
     }

     /**
      * @param mixed $customer_id
      * @return User
      */
     public function setCustomerId($customer_id)
     {
         $this->customer_id = $customer_id;
         return $this;
     }

     /**
      * @return mixed
      */
     public function getId()
     {
         return $this->id;
     }

     /**
      * Set newsletter
      * @param boolean $newsletter
      * @return User
      */
     public function setNewsletter($newsletter)
     {
         $this->newsletter = $newsletter;

         return $this;
     }

     /**
      * Get newsletter
      * @return bool
      */
     public function getNewsletter()
     {
         return $this->newsletter;
     }

     /**
      * Add professional
      *
      * @param \AppBundle\Entity\Addresses $addresses
      *
      * @return User
      */
     public function addAddress(\AppBundle\Entity\Addresses $addresses)
     {
         $addresses->setSalutation($this->salutation);
         $addresses->setFirstName($this->first_name);
         $addresses->setLastName($this->last_name);
         $addresses->setEmail($this->email);
         $addresses->setTelephone($this->telephone);
         $addresses->setStreet($this->street);
         $addresses->setStreetNumber($this->street_number);
         $addresses->setPlz($this->plz);
         $addresses->setCity($this->city);
         $addresses->setCountry($this->country);
         $addresses->setCompany($this->company);
         $addresses->setInvoice(true);
         $addresses->setDelivery(true);
         $addresses->setCustomerId($this->id);
         return $this->addresses = $addresses;
     }
     /**
      * Get addresses
      *
      * @return \Doctrine\Common\Collections\Collection
      */
     public function getAddresses()
     {
         return $this->addresses;
     }

     public function getFullName()
     {
         return $this->first_name.' '.$this->last_name;
     }
 }
</code>```

Addresses Entity:

```<code>namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Table(name="md_addresses")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\AddressesRepository")
 */

class Addresses
{
    /**
     * @var id

     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Id
     */
    protected $id;

    /**
     * @ORM\Column(name="customer_id", type="integer")
     * @ORM\ManyToOne(targetEntity="User", inversedBy="addresses", cascade={"persist"})
     * @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
     */
    protected $customer_id;

    /**
     * @ORM\Column(name="salutation", type="string",length=1)
     */
    protected $salutation;
    /**
     * @var string
     * @ORM\Column(name="first_name", type="string", length=120)
     */

    protected $first_name;

    /**
     * @var string
     * @ORM\Column(name="last_name", type="string", length=255)
     */

    protected $last_name;

    /**
     * @ORM\Column(name="telephone",type="string",length=120)
     */
    protected $telephone;

    /**
     * @ORM\Column(name="email",type="string",length=255)
     */
    protected $email;

    /**
     * @var string
     * @ORM\Column(name="company", type="string", length=255)
     */
    protected $company;

    /**
     * @ORM\Column(type="string", length=255)
     */
    protected $street;

    /**
     * @ORM\Column(type="string", length=30)
     */
    protected $street_number;

    /**
     * @ORM\Column(type="string", length=255)
     */
    protected $additional_1;

    /**
     * @ORM\Column(type="string", length=255)
     */
    protected $additional_2;

    /**
     * @ORM\Column(type="string", length=255)
     */
    protected $additional_3;

    /**
     * @ORM\Column(type="string", length=30)
     */
    protected $plz;
    /**
     * @ORM\Column(type="string", length=100)
     */
    protected $city;

    /**
     * @ORM\Column(type="string", length=10)
     */

    protected $country;
    /**
     * @ORM\Column(type="boolean", options={"default":true})
     */

    protected $invoice;
    /**
     * @ORM\Column(type="boolean", options={"default":true})
     */

    protected $sender;
    /**
     * @ORM\Column(type="boolean", options={"default":true})
     */
    protected $delivery;

      /**
     * @return mixed
     */
    public function getSalutation()
    {
        return $this->salutation;
    }

    /**
     * @param mixed $salutation
     * @return Addresses
     */
    public function setSalutation($salutation)
    {
        $this->salutation = $salutation;
        return $this;
    }

    /**
     * @return string
     */
    public function getCompany()
    {
        return $this->company;
    }

    /**
     * @param string $company
     * @return Addresses
     */
    public function setCompany($company)
    {
        $this->company = $company;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getStreet()
    {
        return $this->street;
    }

    /**
     * @param mixed $street
     * @return Addresses
     */
    public function setStreet($street)
    {
        $this->street = $street;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getStreetNumber()
    {
        return $this->street_number;
    }

    /**
     * @param mixed $street_number
     * @return Addresses
     */
    public function setStreetNumber($street_number)
    {
        $this->street_number = $street_number;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getAdditional1()
    {
        return $this->additional_1;
    }

    /**
     * @param mixed $additional_1
     * @return Addresses
     */
    public function setAdditional1($additional_1)
    {
        $this->additional_1 = $additional_1;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getAdditional2()
    {
        return $this->additional_2;
    }

    /**
     * @param mixed $additional_2
     * @return Addresses
     */
    public function setAdditional2($additional_2)
    {
        $this->additional_2 = $additional_2;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getAdditional3()
    {
        return $this->additional_3;
    }

    /**
     * @param mixed $additional_3
     * @return Addresses
     */
    public function setAdditional3($additional_3)
    {
        $this->additional_3 = $additional_3;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getPlz()
    {
        return $this->plz;
    }

    /**
     * @param mixed $plz
     * @return Addresses
     */
    public function setPlz($plz)
    {
        $this->plz = $plz;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getCity()
    {
        return $this->city;
    }

    /**
     * @param mixed $city
     * @return Addresses
     */
    public function setCity($city)
    {
        $this->city = $city;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getCountry()
    {
        return $this->country;
    }

    /**
     * @param mixed $country
     * @return Addresses
     */
    public function setCountry($country)
    {
        $this->country = $country;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getInvoice()
    {
        return $this->invoice;
    }

    /**
     * @param mixed $invoice
     * @return Addresses
     */
    public function setInvoice($invoice)
    {
        $this->invoice = $invoice;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getSender()
    {
        return $this->sender;
    }

    /**
     * @param mixed $sender
     * @return Addresses
     */
    public function setSender($sender)
    {
        $this->sender = $sender;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getDelivery()
    {
        return $this->delivery;
    }

    /**
     * @param mixed $delivery
     * @return Addresses
     */
    public function setDelivery($delivery)
    {
        $this->delivery = $delivery;
        return $this;
    }

    /**
     * Set user
     * @param \AppBundle\Entity\User $user
     * @return Addresses
     */
    public function setCustomerId(\AppBundle\Entity\User $customer_id = null)
    {
        $this->customer_id = $customer_id;

        return $this;
    }

    /**
     * Get user
     * @return \AppBundle\Entity\User
     */
    public function getCustomerId()
    {
        return $this->customer_id;
    }

    /**
     * @return string
     */
    public function getFirstName()
    {
        return $this->first_name;
    }

    /**
     * @param string $first_name
     * @return Addresses
     */
    public function setFirstName($first_name)
    {
        $this->first_name = $first_name;
        return $this;
    }

    /**
     * @return string
     */
    public function getLastName()
    {
        return $this->last_name;
    }

    /**
     * @param string $last_name
     * @return Addresses
     */
    public function setLastName($last_name)
    {
        $this->last_name = $last_name;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getTelephone()
    {
        return $this->telephone;
    }

    /**
     * @param mixed $telephone
     * @return Addresses
     */
    public function setTelephone($telephone)
    {
        $this->telephone = $telephone;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getEmail()
    {
        return $this->email;
    }

    /**
     * @param mixed $email
     * @return Addresses
     */
    public function setEmail($email)
    {
        $this->email = $email;
        return $this;
    }

}
</code>```

RegistrationType:

```<code>class RegistrationType extends AbstractType
{

    private $session;
    public function __construct(Session $session)
    {
        $this->session = $session;
    }

    public function buildForm(FormBuilderInterface $builder, array $options)
    {

        parent::buildForm($builder, $options);

        $builder ->add('salutation', SalutationType::class,
                        array('placeholder'   => 'form.choice'))
                 ->add('telephone',     TextType::class,array('required' => false))
                 ->remove('username')
                 ->add('first_name',    TextType::class)
                 ->add('mandant',    HiddenType::class,array('data'=>$this->session->get('mandantId')))
                 ->add('last_name',     TextType::class)
                 ->add('company',       TextType::class,array('required' => false))
                 ->add('street',         TextType::class)
                 ->add('street_number',  TextType::class)
                 ->add('ustid',         TextType::class,array('required' => false))
                 ->add('plz', TextType::class)
                 ->add('city', TextType::class)
                 ->add('newsletter',CheckboxType::class,array('label' => false,'required' => false))
                 ->add('country', CountryType::class, [
                    'required' => true,
                    'placeholder' => 'form.choice',
                    'preferred_choices' => [
                        'DE', 'NL', 'BE', 'CH', 'AUT',
                    ]])
                  ->addEventListener(FormEvents::POST_SUBMIT, array($this, 'onPreSetData'));

    }

    public function onPreSetData(FormEvent $event)
    {
        $user = $event->getData();
        $user->addAddress(new Addresses());

        $event->setData($user);

    }

    public function getParent()

    {
        return 'FOS\UserBundle\Form\Type\RegistrationFormType';
    }

    public function getBlockPrefix()

    {
        return 'app_user_registration';
    }

    public function getName()

    {
        return $this->getBlockPrefix();
    }

}
</code>```

UPDATE:

```<code>class RegistrationSubscriber implements EventSubscriberInterface
{

    private $em;

    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }

    public static function getSubscribedEvents()
    {
        return [
            FOSUserEvents::REGISTRATION_COMPLETED => [
                ['onRegistrationSuccess']
                ],
            ];
    }

    public function onRegistrationSuccess(FilterUserResponseEvent $event)
    {
        $user = $event->getUser();
        $address = new Address();
        $address->setSalutation($user->getSalutation());
        $address->setFirstName($user->getFirstName());
        $address->setLastName($user->getLastName());
        $address->setEmail($user->getEmail());
        $address->setTelephone($user->getTelephone());
        $address->setStreet($user->getStreet());
        $address->setStreetNumber($user->getStreetNumber());
        $address->setPlz($user->getPlz());
        $address->setCity($user->getCity());
        $address->setCountry($user->getCountry());
        $address->setCompany($user->getCompany());
        $address->setCustomerId($user->getId());
        $user->addAddress($address);
        $this->em->persist($user);
        $this->em->flush();
    }

}
</code>```

答:
1) How to get the back the field id of md_user from doctrine

Your user entity will automatically get an id when it' s stored in database. You can get it's id with the appropriate getter. This said, you will have to listen to an event, which occurs after the entity was stored in db. I would recommend to rely on FOSUserEvents::REGISTRATION_SUCCESS or FOSUserEvents::REGISTRATION_COMPLETED. See the docs for it's proper usage. You can then access your regsitered user via

```<code> $user = $event->getUser();
</code>```

2) How to save the other data with this id to md_addresses

You create a new address entity, set the desired data including the user to which the address belongs to. Then persist and flush this entity to your db.

Code sample:

```<code>$address = new Address();
$address->setFirstname = $user->getFirstname();
$address->setUser($user);
$em->persist($address);
$em->flush();
</code>```

Body:
I am using FOSUserbundle in symfony 3 and want to use a second table,
where I save the address data.

Therefore I use the extended User Entity and the addresses Entity.

Workflow:

f.e. first_name,last_name,company and all other Formdata should go to md_user table.

copy of first_name,last_name,company etc should go to md_addresses table, which has got the "customer_id" field of md_user.id

To get it working I use the Eventlistener in RegistrationType:

->addEventListener(FormEvents::POST_SUBMIT, array($this, 'onPreSetData'));

and the method:

 public function onPreSetData(FormEvent $event)
{
    $user = $event->getData();
    $user->addAddress(new Addresses());
    $event->setData($user);

}

Before I use $event->setData($user) in RegistrationType, the $user looks like:

My Questions are:

1) How to get the back the field id of md_user from doctrine

2) How to save the other data with this id to md_addresses

Thats what I have done right now.

User Entity:

namespace AppBundle\Entity;

 class User extends BaseUser
{

   /**
     * @ORM\Id
     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * Different Logins for One Customer
     * @ORM\Column(name="customer_id",type="integer",nullable=true,options={"default":null})
     * @ORM\OneToMany(targetEntity="Addresses", mappedBy="user", cascade={"persist","remove"})
     **/
    protected $customer_id;

    /**
      * @var \DateTime
      * @ORM\Column(name="created", type="datetime")
      */
     protected $created;

     /**
      * @ORM\Column(name="mandant",type="integer")
      */
    protected $mandant;

     /**
      * @var string
      * @ORM\Column(name="salutation", type="string", length=1)
      */
     protected $salutation;

     /**
      * @var string
      * @ORM\Column(name="first_name", type="string", length=120)
      * @Assert\Length(
      *     min=2,
      *     max=120,
      *     minMessage="The name is too short.",
      *     maxMessage="The name is too long.",
      *     groups={"Registration", "Profile"}
      * )
      */
     protected $first_name;

     /**
      * @var string
      * @ORM\Column(name="last_name", type="string", length=255)
      * @Assert\Length(
      *     min=2,
      *     max=255,
      *     minMessage="The name is too short.",
      *     maxMessage="The name is too long.",
      *     groups={"Registration", "Profile"}
      * )
      */
     protected $last_name;

     /**
      * @var string
      * @ORM\Column(name="company", type="string", length=255)
      */
     protected $company;

     /**
      * @var string
      * @ORM\Column(type="string", type="string", length=150)
      */
     protected $street;

     /**
      * @var string
      * @ORM\Column(type="string", type="string", length=30)
      */
     protected $street_number;

     /**
      * @var string
      * @ORM\Column(type="string", type="string", length=150)
      */
     protected $city;

     /**
      * @var string
      * @ORM\Column(type="string", type="string", length=150)
      */
     protected $plz;

     /**
      * @var string
      * @ORM\Column(name="ustid", type="string", length=30)
      */
     protected $ustid;

     /**
      * @var string
      * @ORM\Column(name="country", type="string", length=6)
      */
     protected $country;

     /**
      * @ORM\Column(name="telephone",type="string",length=120)
      */
     protected $telephone;

     /**
      * @ORM\Column(name="email_info", type="string",length=255,nullable=true)
      */
     protected $email_info;
     /**
      * @ORM\Column(name="email_invoice", type="string",length=255,nullable=true)
      */
     protected $email_invoice;

     /**
      * @ORM\Column(name="send_info", type="boolean",nullable=true)
      */
     protected $send_info = true;

     /**
      * @ORM\Column(name="invoice_pdf", type="boolean",nullable=true)
      */
     protected $invoice_pdf = true;

     /**
      * @ORM\OneToMany(targetEntity="AppBundle\Entity\Addresses", mappedBy="customer_id", cascade={"persist","remove"})
      */
     protected $addresses;
     /**
      * @var bool
      * @ORM\Column(name="newsletter", type="boolean")
      */
     protected $newsletter=true;

     public function __construct()
     {
         parent::__construct();
         $this->created         = new \DateTime();
//         $this->addresses              = new ArrayCollection();
     }

     /**
      * @return mixed
      */
     public function getEmailInfo()
     {
         return $this->email_info;
     }

     public function setEmailInfo($email_info)
     {
         $this->email_info = is_null($email_info) ? $this->email : $email_info;
         return $this;
     }

     public function getEmailInvoice()
     {
         return $this->email_invoice;
     }

     /**
      * @param mixed $email_invoice
      * @return User
      */
     public function setEmailInvoice($email_invoice)
     {
         $this->email_invoice = is_null($email_invoice) ? $this->email : $email_invoice;
         return $this;
     }

     /**
      * @return mixed
      */
     public function getInvoicePdf()
     {
         return $this->invoice_pdf;
     }

     /**
      * @param mixed $invoice_pdf
      * @return User
      */
     public function setInvoicePdf($invoice_pdf)
     {
         $this->invoice_pdf = $invoice_pdf;
         return $this;
     }

     /**
      * @return mixed
      */
     public function getSendInfo()
     {
         return $this->send_info;
     }

     /**
      * @param mixed $send_info
      * @return User
      */
     public function setSendInfo($send_info)
     {
         $this->send_info = $send_info;
         return $this;
     }

     public function getTelephone()
     {
         return $this->telephone;
     }

     /**
      * @param mixed $telephone
      * @return User
      */
     public function setTelephone($telephone)
     {
         $this->telephone = $telephone;
         return $this;
     }

     public function setEmail($email)
     {
         $email = is_null($email) ? '' : $email;
         parent::setEmail($email);
         $this->setUsername($email);
         return $this;
     }

     /**
      * @return string
      */
     public function getSalutation()
     {
         return $this->salutation;
     }

     /**
      * @param string $saluation
      * @return User
      */
     public function setSalutation($salutation)
     {
         $this->salutation = $salutation;
         return $this;
     }

     /**
      * @return string
      */
     public function getFirstName()
     {
         return $this->first_name;
     }

     /**
      * @param string $first_name
      * @return User
      */
     public function setFirstName($first_name)
     {

         $this->first_name = $first_name;
         return $this;
     }

     /**
      * @return string
      */
     public function getLastName()
     {
         return $this->last_name;
     }

     /**
      * @param string $last_name
      * @return User
      */
     public function setLastName($last_name)
     {
         $this->last_name = $last_name;
         return $this;
     }

     /**
      * @return string
      */
     public function getCompany()
     {
         return $this->company;
     }

     /**
      * @param string $company
      * @return User
      */
     public function setCompany($company)
     {
         $this->company = $company;
         return $this;
     }

     /**
      * @return string
      */
     public function getUstid()
     {
         return $this->ustid;
     }

     /**
      * @param string $ustid
      * @return User
      */
     public function setUstid($ustid)
     {
         $this->ustid = $ustid;
         return $this;
     }

     public function getName()
     {
         return 'user';
     }

     /**
      * @return mixed
      */
     public function getMandant()
     {
         return $this->mandant;
     }

     /**
      * @param mixed $mandant
      * @return User
      */
     public function setMandant($mandant)
     {
         $this->mandant = $mandant;
         return $this;
     }

     /**
      * @return string
      */
     public function getCity()
     {
         return $this->city;
     }

     /**
      * @param string $city
      * @return User
      */
     public function setCity($city)
     {
         $this->city = $city;
         return $this;
     }

     /**
      * @return string
      */
     public function getCountry()
     {
         return $this->country;
     }

     /**
      * @param string $country
      * @return User
      */
     public function setCountry($country)
     {
         $this->country = $country;
         return $this;
     }

     /**
      * @return string
      */
     public function getStreet()
     {
         return $this->street;
     }

     /**
      * @param string $street
      * @return User
      */
     public function setStreet($street)
     {
         $this->street = $street;
         return $this;
     }

     /**
      * @return string
      */
     public function getStreetNumber()
     {
         return $this->street_number;
     }

     /**
      * @param string $street_number
      * @return User
      */
     public function setStreetNumber($street_number)
     {
         $this->street_number = $street_number;
         return $this;
     }

     /**
      * @return string
      */
     public function getPlz()
     {
         return $this->plz;
     }

     /**
      * @param string $plz
      * @return User
      */
     public function setPlz($plz)
     {
         $this->plz = $plz;
         return $this;
     }

     /**
      * Set created
      *
      * @param \DateTime $created
      *
      * @return User
      */
     public function setCreated($created)
     {
         $this->created = $created;

         return $this;
     }

     /**
      * Get created
      *
      * @return \DateTime
      */
     public function getCreated()
     {
         return $this->created;
     }

     /**
      * @return mixed
      */
     public function getCustomerId()
     {
         return $this->customer_id;
     }

     /**
      * @param mixed $customer_id
      * @return User
      */
     public function setCustomerId($customer_id)
     {
         $this->customer_id = $customer_id;
         return $this;
     }

     /**
      * @return mixed
      */
     public function getId()
     {
         return $this->id;
     }

     /**
      * Set newsletter
      * @param boolean $newsletter
      * @return User
      */
     public function setNewsletter($newsletter)
     {
         $this->newsletter = $newsletter;

         return $this;
     }

     /**
      * Get newsletter
      * @return bool
      */
     public function getNewsletter()
     {
         return $this->newsletter;
     }

     /**
      * Add professional
      *
      * @param \AppBundle\Entity\Addresses $addresses
      *
      * @return User
      */
     public function addAddress(\AppBundle\Entity\Addresses $addresses)
     {
         $addresses->setSalutation($this->salutation);
         $addresses->setFirstName($this->first_name);
         $addresses->setLastName($this->last_name);
         $addresses->setEmail($this->email);
         $addresses->setTelephone($this->telephone);
         $addresses->setStreet($this->street);
         $addresses->setStreetNumber($this->street_number);
         $addresses->setPlz($this->plz);
         $addresses->setCity($this->city);
         $addresses->setCountry($this->country);
         $addresses->setCompany($this->company);
         $addresses->setInvoice(true);
         $addresses->setDelivery(true);
         $addresses->setCustomerId($this->id);
         return $this->addresses = $addresses;
     }
     /**
      * Get addresses
      *
      * @return \Doctrine\Common\Collections\Collection
      */
     public function getAddresses()
     {
         return $this->addresses;
     }

     public function getFullName()
     {
         return $this->first_name.' '.$this->last_name;
     }
 }

Addresses Entity:

namespace AppBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Table(name="md_addresses")
 * @ORM\Entity(repositoryClass="AppBundle\Repository\AddressesRepository")
 */

class Addresses
{
    /**
     * @var id

     * @ORM\Column(type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Id
     */
    protected $id;

    /**
     * @ORM\Column(name="customer_id", type="integer")
     * @ORM\ManyToOne(targetEntity="User", inversedBy="addresses", cascade={"persist"})
     * @ORM\JoinColumn(name="customer_id", referencedColumnName="id")
     */
    protected $customer_id;

    /**
     * @ORM\Column(name="salutation", type="string",length=1)
     */
    protected $salutation;
    /**
     * @var string
     * @ORM\Column(name="first_name", type="string", length=120)
     */

    protected $first_name;

    /**
     * @var string
     * @ORM\Column(name="last_name", type="string", length=255)
     */

    protected $last_name;

    /**
     * @ORM\Column(name="telephone",type="string",length=120)
     */
    protected $telephone;

    /**
     * @ORM\Column(name="email",type="string",length=255)
     */
    protected $email;

    /**
     * @var string
     * @ORM\Column(name="company", type="string", length=255)
     */
    protected $company;

    /**
     * @ORM\Column(type="string", length=255)
     */
    protected $street;

    /**
     * @ORM\Column(type="string", length=30)
     */
    protected $street_number;

    /**
     * @ORM\Column(type="string", length=255)
     */
    protected $additional_1;

    /**
     * @ORM\Column(type="string", length=255)
     */
    protected $additional_2;

    /**
     * @ORM\Column(type="string", length=255)
     */
    protected $additional_3;

    /**
     * @ORM\Column(type="string", length=30)
     */
    protected $plz;
    /**
     * @ORM\Column(type="string", length=100)
     */
    protected $city;

    /**
     * @ORM\Column(type="string", length=10)
     */

    protected $country;
    /**
     * @ORM\Column(type="boolean", options={"default":true})
     */

    protected $invoice;
    /**
     * @ORM\Column(type="boolean", options={"default":true})
     */

    protected $sender;
    /**
     * @ORM\Column(type="boolean", options={"default":true})
     */
    protected $delivery;

      /**
     * @return mixed
     */
    public function getSalutation()
    {
        return $this->salutation;
    }

    /**
     * @param mixed $salutation
     * @return Addresses
     */
    public function setSalutation($salutation)
    {
        $this->salutation = $salutation;
        return $this;
    }

    /**
     * @return string
     */
    public function getCompany()
    {
        return $this->company;
    }

    /**
     * @param string $company
     * @return Addresses
     */
    public function setCompany($company)
    {
        $this->company = $company;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getStreet()
    {
        return $this->street;
    }

    /**
     * @param mixed $street
     * @return Addresses
     */
    public function setStreet($street)
    {
        $this->street = $street;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getStreetNumber()
    {
        return $this->street_number;
    }

    /**
     * @param mixed $street_number
     * @return Addresses
     */
    public function setStreetNumber($street_number)
    {
        $this->street_number = $street_number;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getAdditional1()
    {
        return $this->additional_1;
    }

    /**
     * @param mixed $additional_1
     * @return Addresses
     */
    public function setAdditional1($additional_1)
    {
        $this->additional_1 = $additional_1;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getAdditional2()
    {
        return $this->additional_2;
    }

    /**
     * @param mixed $additional_2
     * @return Addresses
     */
    public function setAdditional2($additional_2)
    {
        $this->additional_2 = $additional_2;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getAdditional3()
    {
        return $this->additional_3;
    }

    /**
     * @param mixed $additional_3
     * @return Addresses
     */
    public function setAdditional3($additional_3)
    {
        $this->additional_3 = $additional_3;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getPlz()
    {
        return $this->plz;
    }

    /**
     * @param mixed $plz
     * @return Addresses
     */
    public function setPlz($plz)
    {
        $this->plz = $plz;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getCity()
    {
        return $this->city;
    }

    /**
     * @param mixed $city
     * @return Addresses
     */
    public function setCity($city)
    {
        $this->city = $city;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getCountry()
    {
        return $this->country;
    }

    /**
     * @param mixed $country
     * @return Addresses
     */
    public function setCountry($country)
    {
        $this->country = $country;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getInvoice()
    {
        return $this->invoice;
    }

    /**
     * @param mixed $invoice
     * @return Addresses
     */
    public function setInvoice($invoice)
    {
        $this->invoice = $invoice;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getSender()
    {
        return $this->sender;
    }

    /**
     * @param mixed $sender
     * @return Addresses
     */
    public function setSender($sender)
    {
        $this->sender = $sender;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getDelivery()
    {
        return $this->delivery;
    }

    /**
     * @param mixed $delivery
     * @return Addresses
     */
    public function setDelivery($delivery)
    {
        $this->delivery = $delivery;
        return $this;
    }

    /**
     * Set user
     * @param \AppBundle\Entity\User $user
     * @return Addresses
     */
    public function setCustomerId(\AppBundle\Entity\User $customer_id = null)
    {
        $this->customer_id = $customer_id;

        return $this;
    }

    /**
     * Get user
     * @return \AppBundle\Entity\User
     */
    public function getCustomerId()
    {
        return $this->customer_id;
    }

    /**
     * @return string
     */
    public function getFirstName()
    {
        return $this->first_name;
    }

    /**
     * @param string $first_name
     * @return Addresses
     */
    public function setFirstName($first_name)
    {
        $this->first_name = $first_name;
        return $this;
    }

    /**
     * @return string
     */
    public function getLastName()
    {
        return $this->last_name;
    }

    /**
     * @param string $last_name
     * @return Addresses
     */
    public function setLastName($last_name)
    {
        $this->last_name = $last_name;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getTelephone()
    {
        return $this->telephone;
    }

    /**
     * @param mixed $telephone
     * @return Addresses
     */
    public function setTelephone($telephone)
    {
        $this->telephone = $telephone;
        return $this;
    }

    /**
     * @return mixed
     */
    public function getEmail()
    {
        return $this->email;
    }

    /**
     * @param mixed $email
     * @return Addresses
     */
    public function setEmail($email)
    {
        $this->email = $email;
        return $this;
    }

}

RegistrationType:

class RegistrationType extends AbstractType
{

    private $session;
    public function __construct(Session $session)
    {
        $this->session = $session;
    }

    public function buildForm(FormBuilderInterface $builder, array $options)
    {

        parent::buildForm($builder, $options);

        $builder ->add('salutation', SalutationType::class,
                        array('placeholder'   => 'form.choice'))
                 ->add('telephone',     TextType::class,array('required' => false))
                 ->remove('username')
                 ->add('first_name',    TextType::class)
                 ->add('mandant',    HiddenType::class,array('data'=>$this->session->get('mandantId')))
                 ->add('last_name',     TextType::class)
                 ->add('company',       TextType::class,array('required' => false))
                 ->add('street',         TextType::class)
                 ->add('street_number',  TextType::class)
                 ->add('ustid',         TextType::class,array('required' => false))
                 ->add('plz', TextType::class)
                 ->add('city', TextType::class)
                 ->add('newsletter',CheckboxType::class,array('label' => false,'required' => false))
                 ->add('country', CountryType::class, [
                    'required' => true,
                    'placeholder' => 'form.choice',
                    'preferred_choices' => [
                        'DE', 'NL', 'BE', 'CH', 'AUT',
                    ]])
                  ->addEventListener(FormEvents::POST_SUBMIT, array($this, 'onPreSetData'));

    }

    public function onPreSetData(FormEvent $event)
    {
        $user = $event->getData();
        $user->addAddress(new Addresses());

        $event->setData($user);

    }

    public function getParent()

    {
        return 'FOS\UserBundle\Form\Type\RegistrationFormType';
    }

    public function getBlockPrefix()

    {
        return 'app_user_registration';
    }

    public function getName()

    {
        return $this->getBlockPrefix();
    }

}

UPDATE:

class RegistrationSubscriber implements EventSubscriberInterface
{

    private $em;

    public function __construct(EntityManager $em)
    {
        $this->em = $em;
    }

    public static function getSubscribedEvents()
    {
        return [
            FOSUserEvents::REGISTRATION_COMPLETED => [
                ['onRegistrationSuccess']
                ],
            ];
    }

    public function onRegistrationSuccess(FilterUserResponseEvent $event)
    {
        $user = $event->getUser();
        $address = new Address();
        $address->setSalutation($user->getSalutation());
        $address->setFirstName($user->getFirstName());
        $address->setLastName($user->getLastName());
        $address->setEmail($user->getEmail());
        $address->setTelephone($user->getTelephone());
        $address->setStreet($user->getStreet());
        $address->setStreetNumber($user->getStreetNumber());
        $address->setPlz($user->getPlz());
        $address->setCity($user->getCity());
        $address->setCountry($user->getCountry());
        $address->setCompany($user->getCompany());
        $address->setCustomerId($user->getId());
        $user->addAddress($address);
        $this->em->persist($user);
        $this->em->flush();
    }

}

Body:
1) How to get the back the field id of md_user from doctrine

Your user entity will automatically get an id when it' s stored in database. You can get it's id with the appropriate getter. This said, you will have to listen to an event, which occurs after the entity was stored in db. I would recommend to rely on FOSUserEvents::REGISTRATION_SUCCESS or FOSUserEvents::REGISTRATION_COMPLETED. See the docs for it's proper usage. You can then access your regsitered user via

 $user = $event->getUser();

2) How to save the other data with this id to md_addresses

You create a new address entity, set the desired data including the user to which the address belongs to. Then persist and flush this entity to your db.

Code sample:

$address = new Address();
$address->setFirstname = $user->getFirstname();
$address->setUser($user);
$em->persist($address);
$em->flush();


问:
expo Unhandled Promise Rejection
I worked on a project with expo/react-native and everything work fine in ios simulator but I'm getting this error on android emulator(Genymotion) and on my iPhone device.

I attached the screenshot.

android screenshot

答:
Every promise must have an associated catch for error handling purposes to remove the warning.

If .then() was used, then you need to have a .catch() linked to it.

If try {} was used, then you need to have a catch {} linked to it.

Title: expo Unhandled Promise Rejection


问:
Local site redirect to wrong address
So i have Ubuntu 16.04 with apache2 installed on it, and my local sites are inside if /var/www/html/ directory.

The problem is that one of my sites based on magento 1.9 redirect me to wrong url everytime. Whenever i'm trying to access localhost/my-site/ it redirects me to localhost/my-site/localhost/my-site/ instead.

I have tried to change .htaccess and even deleting it from site root folder same as changing apache2 hosts configurations inside of apache2/site-available folder and even creating new virtual host in that folder but that didn't helped.

I also tried to fully reinstall apache but no result. My hosts file has just localhost defined now so it can not be conflict with other host.

I think that it replace index.php url part with localhost/my-site but i have no idea how to fix it.

I would realy appreciate some help becose i'm trying to fix this few day already with no result.

Thanks.

答:
Ok, I have solved this problem, by deleting cache folder on my local pc in /var/tmp directory. Apparently this cache was saved when i got redirect first time and after that i was redirecter becose of this.

Hope this will help someone.

Title: Local site redirect to wrong address


问:
Lexical environment example explanation
I am following a JS tutorial and have come across this example below, and the first one makes sense from what I have learned so far:

```<code>function makeCounter() {
  function counter() {
    return counter.count++;
  };
  counter.count = 0;

  return counter;
}

let counter = makeCounter();
let counter1 = makeCounter();
console.log(counter());  // 0
console.log(counter());  // 1
console.log(counter1()); // 0
</code>```

So, that makes sense since the new lexical environments are created each time we assign the makeCounter function to a new variable. What I don't understand is if I am using the property of the function makeCounter I am still incrementing the makeCounter.count if I assign it to new variables:

```<code>function makeCounter() {
  function counter() {
    return makeCounter.count++;
  };
  makeCounter.count = 0;

  return counter;
}

let counter = makeCounter();
let counter1 = makeCounter();
console.log(counter());  // 0
console.log(counter());  // 1
console.log(counter1()); // 2
</code>```

答:
I think using a property of the function object is quite confusing here, especially if you want to learn about lexical environments. A better example might be the difference between

```<code>function makeCounter() {
  var count = 0;
  function counter() {
    return count++;
  }
  return counter;
}
</code>```

and

```<code>var count = 0;
function makeCounter() {
  function counter() {
    return count++;
  }
  return counter;
}
</code>```

where it is more obvious how many count variables there are, when they are created, and in which scope they live. Of course it works the same with the indirection through the counter vs makeCounter variables (that get initialised with function objects), which live in the same scopes as count does in my examples.

Admittedly, makeCounter.count = 0 should better be outside of makeCounter, as otherwise the behaviour of resetting the global count will get really confusing. The exact property-less code corresponding to yours would be

```<code>function makeCounter() {
  var count;
  function counter() {
    return count++;
  }
  count = 0;
  return counter;
}
</code>```

vs

```<code>var count;
function makeCounter() {
  function counter() {
    return count++;
  }
  count = 0;
  return counter;
}
</code>```

Title: Lexical environment example explanation

Body:
I am following a JS tutorial and have come across this example below, and the first one makes sense from what I have learned so far:

function makeCounter() {
  function counter() {
    return counter.count++;
  };
  counter.count = 0;

  return counter;
}

let counter = makeCounter();
let counter1 = makeCounter();
console.log(counter());  // 0
console.log(counter());  // 1
console.log(counter1()); // 0

So, that makes sense since the new lexical environments are created each time we assign the makeCounter function to a new variable. What I don't understand is if I am using the property of the function makeCounter I am still incrementing the makeCounter.count if I assign it to new variables:

function makeCounter() {
  function counter() {
    return makeCounter.count++;
  };
  makeCounter.count = 0;

  return counter;
}

let counter = makeCounter();
let counter1 = makeCounter();
console.log(counter());  // 0
console.log(counter());  // 1
console.log(counter1()); // 2

Body:
I think using a property of the function object is quite confusing here, especially if you want to learn about lexical environments. A better example might be the difference between

function makeCounter() {
  var count = 0;
  function counter() {
    return count++;
  }
  return counter;
}

and

var count = 0;
function makeCounter() {
  function counter() {
    return count++;
  }
  return counter;
}

where it is more obvious how many count variables there are, when they are created, and in which scope they live. Of course it works the same with the indirection through the counter vs makeCounter variables (that get initialised with function objects), which live in the same scopes as count does in my examples.

Admittedly, makeCounter.count = 0 should better be outside of makeCounter, as otherwise the behaviour of resetting the global count will get really confusing. The exact property-less code corresponding to yours would be

function makeCounter() {
  var count;
  function counter() {
    return count++;
  }
  count = 0;
  return counter;
}

vs

var count;
function makeCounter() {
  function counter() {
    return count++;
  }
  count = 0;
  return counter;
}


问:
Word comparison algorithm
I am doing a CSV Import tool for the project I'm working on.
The client needs to be able to enter the data in excel, export them as CSV and upload them to the database.
For example I have this CSV record:

```<code>   1,   John Doe,     ACME Comapny   (the typo is on purpose)
</code>```

Of course, the companies are kept in a separate table and linked with a foreign key, so I need to discover the correct company ID before inserting.
I plan to do this by comparing the company names in the database with the company names in the CSV.
the comparison should return 0 if the strings are exactly the same, and return some value that gets bigger as the strings get more different, but strcmp doesn't cut it here because:

"Acme Company" and "Acme Comapny" should have a very small difference index, but
"Acme Company" and "Cmea Mpnyaco" should have a very big difference index
Or "Acme Company" and "Acme Comp." should also have a small difference index, even though the character count is different.
Also, "Acme Company" and "Company Acme" should return 0.

So if the client makes a type while entering data, i could prompt him to choose the name he most probably wanted to insert.

Is there a known algorithm to do this, or maybe we can invent one :)
?

答:
You might want to check out the Levenshtein Distance algorithm as a starting point.  It will rate the "distance" between two words.

This SO thread on implementing a Google-style "Do you mean...?" system may provide some ideas as well.

OwnerDisplayName: Discodancer

ContentLicense: CC BY-SA 2.5

Title: Word comparison algorithm

Body:
I am doing a CSV Import tool for the project I'm working on.
The client needs to be able to enter the data in excel, export them as CSV and upload them to the database.
For example I have this CSV record:

   1,   John Doe,     ACME Comapny   (the typo is on purpose)

Of course, the companies are kept in a separate table and linked with a foreign key, so I need to discover the correct company ID before inserting.
I plan to do this by comparing the company names in the database with the company names in the CSV.
the comparison should return 0 if the strings are exactly the same, and return some value that gets bigger as the strings get more different, but strcmp doesn't cut it here because:

"Acme Company" and "Acme Comapny" should have a very small difference index, but
"Acme Company" and "Cmea Mpnyaco" should have a very big difference index
Or "Acme Company" and "Acme Comp." should also have a small difference index, even though the character count is different.
Also, "Acme Company" and "Company Acme" should return 0.

So if the client makes a type while entering data, i could prompt him to choose the name he most probably wanted to insert.

Is there a known algorithm to do this, or maybe we can invent one :)
?

OwnerDisplayName: MattK


问:
jQuery .load() - corner plugin not working in IE - Firefox is ok
I have two simple pages I'm using for testing.

On my first page, I use $.load() to load a div from the second page.

Both pages contains the plugin to do the cornering. If I load the first page which loads the div from the second page, the cornering does not work. However, if I load the second page myself, the cornering does work so it's to do with $.load().

Here's some code, from page 1:

```<code> <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>

        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

        <script type="text/javascript">
            $(document).ready(function() {
                $("#load").load('testLoadCornering2.aspx #loadMe');
            });
        </script>

        <script src="resources/js/curvycorners.js" type="text/javascript"></script>

        <script src="resources/js/curvycorners.src.js" type="text/javascript"></script>

        <link href="resources/css/main.css" rel="stylesheet" type="text/css" />
        <link href="resources/css/buttons.css" rel="stylesheet" type="text/css" />
        <link href="resources/css/confirm.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form id="form1" runat="server">
        <div id="load" class="BWTable">
        </div>
        </form>
    </body>
    </html>
</code>```

You see the page trying to load the second div.

And the second page:

```<code><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

    <script src="resources/js/curvycorners.js" type="text/javascript"></script>

    <script src="resources/js/curvycorners.src.js" type="text/javascript"></script>

    <link href="resources/css/main.css" rel="stylesheet" type="text/css" />
    <link href="resources/css/buttons.css" rel="stylesheet" type="text/css" />
    <link href="resources/css/confirm.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div id="loadMe" class="BWTable">
        <p>
            Test Test Test Test Test Test Test
        </p>
    </div>
    </form>
</body>
</html>
</code>```

And the CSS it uses for the rounding (along with the rounded corners plugin):

```<code> background-image: url(         '../../images/wp_form2.gif' );
 border: solid 1px #000000;
 margin-left: auto;
 margin-right: auto;
 text-align: center;
 color: white;
 -moz-border-radius: 10px; /* Rounded corners plugin */
 -webkit-border-radius: 10px; /* Rounded corners plugin */
</code>```

In Firefox, this works fine - but in IE (specially version 8 I've been trying) the corners are never rounded.

To reiterate, manually going to the second page in IE 8 corners correctly, it's only when the .load() method is used.

Any help appreciated.

Note: I'm aware I shouldn't need to add the style sheets on both pages etc as they should be loaded from the first page, but I've added them to show you the full code of what it's trying to do.
Thanks,
Ricky

答:
Thanks Lazarus. You put me on the right tracks and I've worked out the solution, this works. I feel a bit silly now!

Thanks again.

Page 1:

```<code><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

    <link href="resources/css/main.css" rel="stylesheet" type="text/css" />
    <link href="resources/css/buttons.css" rel="stylesheet" type="text/css" />
    <link href="resources/css/confirm.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        $(document).ready(function() {

        $("#load").load('testLoadCornering2.aspx #loadMe');

            $.getScript('resources/js/curvycorners.js', function() {
                $(this).init();
            });
            $.getScript('resources/js/curvycorners.src.js', function() {
                $(this).init();
            });
        });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div id="load" class="BWTable">
    </div>
    </form>
</body>
</html>
</code>```

Page 2:

```<code><html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div id="loadMe" class="BWTable">
        <p>
            Test Test Test Test Test Test Test
        </p>
    </div>

    </form>
</body>
</html>
</code>```

Body:
I have two simple pages I'm using for testing.

On my first page, I use $.load() to load a div from the second page.

Both pages contains the plugin to do the cornering. If I load the first page which loads the div from the second page, the cornering does not work. However, if I load the second page myself, the cornering does work so it's to do with $.load().

Here's some code, from page 1:

        <title>Untitled Page</title>

        <link href="resources/css/main.css" rel="stylesheet" type="text/css" />
        <link href="resources/css/buttons.css" rel="stylesheet" type="text/css" />
        <link href="resources/css/confirm.css" rel="stylesheet" type="text/css" />

        <form id="form1" runat="server">

        </form>

You see the page trying to load the second div.

And the second page:

    <title>Untitled Page</title>

    <link href="resources/css/main.css" rel="stylesheet" type="text/css" />
    <link href="resources/css/buttons.css" rel="stylesheet" type="text/css" />
    <link href="resources/css/confirm.css" rel="stylesheet" type="text/css" />

    <form id="form1" runat="server">

            Test Test Test Test Test Test Test

    </form>

And the CSS it uses for the rounding (along with the rounded corners plugin):

 background-image: url(         '../../images/wp_form2.gif' );
 border: solid 1px #000000;
 margin-left: auto;
 margin-right: auto;
 text-align: center;
 color: white;
 -moz-border-radius: 10px; /* Rounded corners plugin */
 -webkit-border-radius: 10px; /* Rounded corners plugin */

In Firefox, this works fine - but in IE (specially version 8 I've been trying) the corners are never rounded.

To reiterate, manually going to the second page in IE 8 corners correctly, it's only when the .load() method is used.

Any help appreciated.

Note: I'm aware I shouldn't need to add the style sheets on both pages etc as they should be loaded from the first page, but I've added them to show you the full code of what it's trying to do.
Thanks,
Ricky

Body:
Thanks Lazarus. You put me on the right tracks and I've worked out the solution, this works. I feel a bit silly now!

Thanks again.

Page 1:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>

    <link href="resources/css/main.css" rel="stylesheet" type="text/css" />
    <link href="resources/css/buttons.css" rel="stylesheet" type="text/css" />
    <link href="resources/css/confirm.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        $(document).ready(function() {

        $("#load").load('testLoadCornering2.aspx #loadMe');

            $.getScript('resources/js/curvycorners.js', function() {
                $(this).init();
            });
            $.getScript('resources/js/curvycorners.src.js', function() {
                $(this).init();
            });
        });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div id="load" class="BWTable">
    </div>
    </form>
</body>
</html>

Page 2:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div id="loadMe" class="BWTable">
        <p>
            Test Test Test Test Test Test Test
        </p>
    </div>

    </form>
</body>
</html>


问:
Revocation endpoint in Azure AD B2C
Is there a way to revoke a specific refresh token in Azure AD B2C? It's for the user's management of third app and data access delegation.

I only find this method: Revoke-AzureADUserAllRefreshToken

I don't know if it will work with Azure AD B2C and it clearly doesn't fit with third app management and opt-out.

答:
Outdated, see update below.
There is no way today to revoke tokens in Azure AD B2C. You can request this via the Azure AD B2C feedback forum.

The Revoke-AzureADUserAllRefershToken command only works for regular Azure AD and will not work for Azure AD B2C.

UPDATE FROM 2018-03-08

The Revoke-AzureADUserAllRefreshToken command can be used to revoke refresh Azure AD B2C tokens.

Title: Revocation endpoint in Azure AD B2C


问:
Not show hr through teeny_mce_buttons filter
I'm building custom tinymce bar buttons for my wp theme, using wp_editor and teeny, but I have a problem. When I add hr and charmap, these buttons not appear in the tinymce bar.

This is the wp_editor configuration:

```<code> $settings = array(
                'textarea_name' => 'xor_options[' . $editor . ']',
                'quicktags'     => array( 'buttons' => 'strong,em,del,ul,ol,li,close' ),
                'media_buttons' => true,
                'wpautop'   => false,
                'textarea_rows' => 5,
                'editor_height' => 200,
                'teeny' => true,
                'tinymce' => true
        );
 wp_editor( $xor_output, $xor_editor_id, $settings );
</code>```

Now I'm using the filter for teeny buttons.

```<code>add_filter( 'teeny_mce_buttons', 'xor_editor_buttons', 10, 2 );
function xor_editor_buttons( $buttons, $editor_id ) {

    if( $editor_id != 'footer-editor' ) return $buttons;

    $buttons = array(
        'undo',
        'redo',
        'formatselect',
        'bold',
        'italic',
        'underline',
        'strikethrough',
        'blockquote',
        'bullist',
        'numlist',
        'outdent',
        'indent',
        'alignleft',
        'alignright',
        'aligncenter',
        'alignjustify',
        'link',
        'unlink',
        'hr', // not appears!
        'charmap', // not appears!
        'removeformat',
        'fullscreen'
        );

    return $buttons;
}
</code>```

Where is the error in my code or this is a little bug? I'm using Wordpress 4.9. Thanks!

SOLVED

I set on false teeny. Then I set tinymce as array:

```<code>'tinymce'       => array(
            'toolbar1'      => $b,
            'toolbar2'      => '',
            'toolbar3'      => '',
        )
</code>```

Where $b is all buttons that I need (included hr and charmap). See:
 Wordpress Developers

答:
Before you can load the toolbar buttons you need to load the plugins:

https://www.tinymce.com/docs/plugins/hr/
https://www.tinymce.com/docs/plugins/charmap/

You first need to see if the TinyMCE embedded in your WP version includes these plugins (they are in a standard WordPress setup).  You then need to add these plugins to the list of loaded plugins.  Once they are loaded adding the buttons to the toolbar will work.

I don't know anything about teenymce but (as an example) this is how TinyMCE Advanced loads extra plugins via a WordPress hook:

```<code> add_filter( 'tiny_mce_plugins', array( $this, 'tiny_mce_plugins' ), 999 );
</code>```

(The array is a list of plugin folder names)

Body:
I'm building custom tinymce bar buttons for my wp theme, using wp_editor and teeny, but I have a problem. When I add hr and charmap, these buttons not appear in the tinymce bar.

This is the wp_editor configuration:

 $settings = array(
                'textarea_name' => 'xor_options[' . $editor . ']',
                'quicktags'     => array( 'buttons' => 'strong,em,del,ul,ol,li,close' ),
                'media_buttons' => true,
                'wpautop'   => false,
                'textarea_rows' => 5,
                'editor_height' => 200,
                'teeny' => true,
                'tinymce' => true
        );
 wp_editor( $xor_output, $xor_editor_id, $settings );

Now I'm using the filter for teeny buttons.

add_filter( 'teeny_mce_buttons', 'xor_editor_buttons', 10, 2 );
function xor_editor_buttons( $buttons, $editor_id ) {

    if( $editor_id != 'footer-editor' ) return $buttons;

    $buttons = array(
        'undo',
        'redo',
        'formatselect',
        'bold',
        'italic',
        'underline',
        'strikethrough',
        'blockquote',
        'bullist',
        'numlist',
        'outdent',
        'indent',
        'alignleft',
        'alignright',
        'aligncenter',
        'alignjustify',
        'link',
        'unlink',
        'hr', // not appears!
        'charmap', // not appears!
        'removeformat',
        'fullscreen'
        );

    return $buttons;
}

Where is the error in my code or this is a little bug? I'm using Wordpress 4.9. Thanks!

SOLVED

I set on false teeny. Then I set tinymce as array:

'tinymce'       => array(
            'toolbar1'      => $b,
            'toolbar2'      => '',
            'toolbar3'      => '',
        )

Where $b is all buttons that I need (included hr and charmap). See:
 Wordpress Developers

Body:
Before you can load the toolbar buttons you need to load the plugins:

https://www.tinymce.com/docs/plugins/hr/
https://www.tinymce.com/docs/plugins/charmap/

You first need to see if the TinyMCE embedded in your WP version includes these plugins (they are in a standard WordPress setup).  You then need to add these plugins to the list of loaded plugins.  Once they are loaded adding the buttons to the toolbar will work.

I don't know anything about teenymce but (as an example) this is how TinyMCE Advanced loads extra plugins via a WordPress hook:

 add_filter( 'tiny_mce_plugins', array( $this, 'tiny_mce_plugins' ), 999 );

(The array is a list of plugin folder names)


问:
Find PHP version on windows command line
I just tried to know version of my PHP from windows command typing,
C:\> php -v
But it is not working. It says php is not recognized as internal or external command.

答:
Easy Method is:
Just copy the file cmd.exe from c:/windows/system32/ and paste it to C:\xampp\php\
and run it,
when the cmd opens type " php -v " without quotes and hit enter...
you will get your php version..
thank you</p>


问:
iOS11 bluetooth has something strange
When I switch off the Bluetooth in setting, then I use CBCentralManager to get the state of the Bluetooth like this:

```<code>self.bluetoothManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];
</code>```

the system will display a alert like this: system alert

The current state of Bluetooth is CBManagerStatePoweredOff. But when I switch off the Bluetooth in control center, this alert is not show anymore even if the current state of Bluetooth is still CBManagerStatePoweredOff.

How could I remind the user to switch on the Bluetooth in this situation?

答:
You can disable system BlueTooth alert by using CBCentralManagerOptionShowPowerAlertKey in options dict.

```<code>NSDictionary *options = @{CBCentralManagerOptionShowPowerAlertKey: @NO};
self.bluetoothManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:options];
</code>```

Then you can using deleget method centralManagerDidUpdateState: to popup you custom alert.

Title: iOS11 bluetooth has something strange

Body:
When I switch off the Bluetooth in setting, then I use CBCentralManager to get the state of the Bluetooth like this:

self.bluetoothManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil];

the system will display a alert like this: system alert

The current state of Bluetooth is CBManagerStatePoweredOff. But when I switch off the Bluetooth in control center, this alert is not show anymore even if the current state of Bluetooth is still CBManagerStatePoweredOff.

How could I remind the user to switch on the Bluetooth in this situation?

Body:
You can disable system BlueTooth alert by using CBCentralManagerOptionShowPowerAlertKey in options dict.

NSDictionary *options = @{CBCentralManagerOptionShowPowerAlertKey: @NO};
self.bluetoothManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil options:options];

Then you can using deleget method centralManagerDidUpdateState: to popup you custom alert.


问:
Oracle - trigger after update
I have trigger:

```<code>CREATE OR REPLACE TRIGGER TR.TR_OUTPUT_EHT_UPDATE_OPE
  AFTER DELETE
  ON TR.TR_JN_OUTPUT_EHT
  FOR EACH ROW
DECLARE
   BEGIN
  UPDATE TR.TR_BP tbp
    SET tbp.DONE= 2, tbp.DATA_WYK = SYSDATE
    WHERE EXISTS (SELECT ARCH.NR
    FROM TR.TR_KB_OUTPUT_ARCH ARCH
        WHERE ARCH.NR = tbp.NRKK)
    AND NOT EXISTS (SELECT OUTPUT.NR_SERYJNY
        FROM TR.TR_JN_OUTPUT OUTPUT
        WHERE OUTPUT.NR = tbp.NRKK);
END;
/
</code>```

After that I want to get the "NRKK" of just updated row and update another table which is connected by this "NRKK":

```<code>UPDATE P.TR_OPE OPE
SET OPE.DATA = SYSDATE,
OPE.STATUS = OPE.STATUS + 1
WHERE OPE.NRKK = "NRKK"
</code>```

I tried to do:

```<code>SELECT tbp.NRKK INTO v_nrkk FROM TR.TR_BP tbp WHERE tbp.DATA = (SELECT
MAX(tbp.DATA) FROM TR.TR_BP tbp1);
</code>```

but I have errors: ORA 04091, ORA 06512 and ORA 04088.

EDITED:

I created another trigger:

```<code>CREATE OR REPLACE TRIGGER TR.TR_OP_E
  AFTER UPDATE ON TR.TR_BP
FOR EACH ROW
DECLARE
    v_nrkk TR.TR_BP.NRKK % TYPE;
BEGIN
  SELECT tbp.NRKK INTO v_nrkk FROM TR.TR_BPtbp WHERE tbp.DATA = (SELECT
MAX(tbp.DATA) FROM TR.TR_BP tbp1);

  IF v_nrkk is NOT NULL THEN
  UPDATE P.TR_OPE OPE
    SET OPE.DATA = SYSDATE, OPE.STATUS = 1
    WHERE OPE.ID_BR = '00100300'
    AND OPE.NRKK = v_nrkk;
  END IF;
  END;
/
</code>```

But I have still errors...

答:
As mentioned by @Renato Afonso, you can avoid mutating table error via using a COMPOUND TRIGGER. See below demo;

--Tables

```<code>CREATE TABLE TABLE_1 (data NUMBER);
/
CREATE TABLE TABLE_2 (DATA1 NUMBER);
/
</code>```

--Record in table_1

```<code>SQL> select * from TABLE_1;

      DATA
----------
         1
</code>```

--Record in table_2

```<code>SQL> select * from TABLE_2;

     DATA1
----------
         5
</code>```

Trigger:

```<code>CREATE OR REPLACE TRIGGER TR_OP_E FOR
   INSERT OR UPDATE OR DELETE
   ON TABLE_1
   COMPOUND TRIGGER
   v_nrkk   TABLE_1.DATA%TYPE;
   AFTER STATEMENT
   IS
   BEGIN
      --Selecting from the same table on which trigger is created
      SELECT tbp.data
        INTO v_nrkk
        FROM Table_1 tbp
       WHERE tbp.DATA = (SELECT MAX (tbp.DATA)
                           FROM Table_1 tbp1);

      IF v_nrkk IS NOT NULL
      THEN
         UPDATE TABLE_2 OPE
            SET OPE.DATA1 = v_nrkk;
      END IF;
   END
   AFTER STATEMENT;

END;
/
</code>```

Execution:

```<code>SQL> UPDATE TABLE_1 SET DATA = 2;

1 row updated.

SQL> COMMIT;

Commit complete.

SQL> select * from TABLE_1;

      DATA
----------
         2

SQL>  select * from TABLE_2;

     DATA1
----------
         2
</code>```

Title: Oracle - trigger after update

Body:
I have trigger:

CREATE OR REPLACE TRIGGER TR.TR_OUTPUT_EHT_UPDATE_OPE
  AFTER DELETE
  ON TR.TR_JN_OUTPUT_EHT
  FOR EACH ROW
DECLARE
   BEGIN
  UPDATE TR.TR_BP tbp
    SET tbp.DONE= 2, tbp.DATA_WYK = SYSDATE
    WHERE EXISTS (SELECT ARCH.NR
    FROM TR.TR_KB_OUTPUT_ARCH ARCH
        WHERE ARCH.NR = tbp.NRKK)
    AND NOT EXISTS (SELECT OUTPUT.NR_SERYJNY
        FROM TR.TR_JN_OUTPUT OUTPUT
        WHERE OUTPUT.NR = tbp.NRKK);
END;
/

After that I want to get the "NRKK" of just updated row and update another table which is connected by this "NRKK":

UPDATE P.TR_OPE OPE
SET OPE.DATA = SYSDATE,
OPE.STATUS = OPE.STATUS + 1
WHERE OPE.NRKK = "NRKK"

I tried to do:

SELECT tbp.NRKK INTO v_nrkk FROM TR.TR_BP tbp WHERE tbp.DATA = (SELECT
MAX(tbp.DATA) FROM TR.TR_BP tbp1);

but I have errors: ORA 04091, ORA 06512 and ORA 04088.

EDITED:

I created another trigger:

CREATE OR REPLACE TRIGGER TR.TR_OP_E
  AFTER UPDATE ON TR.TR_BP
FOR EACH ROW
DECLARE
    v_nrkk TR.TR_BP.NRKK % TYPE;
BEGIN
  SELECT tbp.NRKK INTO v_nrkk FROM TR.TR_BPtbp WHERE tbp.DATA = (SELECT
MAX(tbp.DATA) FROM TR.TR_BP tbp1);

  IF v_nrkk is NOT NULL THEN
  UPDATE P.TR_OPE OPE
    SET OPE.DATA = SYSDATE, OPE.STATUS = 1
    WHERE OPE.ID_BR = '00100300'
    AND OPE.NRKK = v_nrkk;
  END IF;
  END;
/

But I have still errors...

Body:
As mentioned by @Renato Afonso, you can avoid mutating table error via using a COMPOUND TRIGGER. See below demo;

--Tables

CREATE TABLE TABLE_1 (data NUMBER);
/
CREATE TABLE TABLE_2 (DATA1 NUMBER);
/

--Record in table_1

SQL> select * from TABLE_1;

      DATA
----------
         1

--Record in table_2

SQL> select * from TABLE_2;

     DATA1
----------
         5

Trigger:

CREATE OR REPLACE TRIGGER TR_OP_E FOR
   INSERT OR UPDATE OR DELETE
   ON TABLE_1
   COMPOUND TRIGGER
   v_nrkk   TABLE_1.DATA%TYPE;
   AFTER STATEMENT
   IS
   BEGIN
      --Selecting from the same table on which trigger is created
      SELECT tbp.data
        INTO v_nrkk
        FROM Table_1 tbp
       WHERE tbp.DATA = (SELECT MAX (tbp.DATA)
                           FROM Table_1 tbp1);

      IF v_nrkk IS NOT NULL
      THEN
         UPDATE TABLE_2 OPE
            SET OPE.DATA1 = v_nrkk;
      END IF;
   END
   AFTER STATEMENT;

END;
/

Execution:

SQL> UPDATE TABLE_1 SET DATA = 2;

1 row updated.

SQL> COMMIT;

Commit complete.

SQL> select * from TABLE_1;

      DATA
----------
         2

SQL>  select * from TABLE_2;

     DATA1
----------
         2


问:
Why we have to do a regular commit immediately after conflicts resolved in Git?
Why we have to do a regular commit immediately after conflicts resolved in Git?

What if I modify some other files after conflicts resolved, then commit them together?

What is the difference?

答:
You have to do a commit because the last step of a merge is a (usually behind-the-scenes) commit, and when there are conflicts git leaves that step out.  So rather than create a new command or sub-command for this situation, it was decided to just let you finish the last step after you'd tidied up the index.

You can make changes other than conflict resolutions.  Sometimes this is necessary to properly resolve the conflict.  It wouldn't be possible for git to "know" if the changes you make are truly needed for conflict resolution.  I suppose it could detect changes that weren't inside conflict markers and issue a warning, but a hard stop would prevent legitimate resolutions in some conflict scenarios and it doesn't seem worth the extra effort that would be involved for a warning.  So instead the developer is trusted to do what they should do.

Besides, did you know that you can specifically tell git not to commit the merge, so that you can edit the merge result (even though there were no conflicts) before committing it?  You probably shouldn't, but you can.

Be aware that making changes that aren't actual conflict resolution in a merge may have negative effects down the road, because those changes are somewhat "hidden" in the merge commit, such that you have to know to look for them.

But git is a powerful tool, and generally it expects you to know how to use that power.  The ability to commit the content you want in commits with the parent(s) you want is part of that power.


问:
Calling javascript form php
I am having a form inside a php script. I am doing the validation using javascript.

```<code><?php

$con = mysql_connect("servername","login","passsword");
if (!$con)
    {
        die('Could not connect: ' . mysql_error());
    }

mysql_select_db("dbadminatms", $con);

if (isset($_POST['email']) && isset($_POST['name']) && isset($_POST['comments']))
{
    $sql="INSERT INTO feedback_comments (posted_by, email, comments_text, comment_date)
        VALUES
    ('$_POST[name]','$_POST[email]','$_POST[comments]',NOW())";
    $emailID = $_POST['email'];
    $postedBy = $_POST['name'];
    $message = $_POST['comments'];

    if (!mysql_query($sql,$con))
    {
        die('Error: ' . mysql_error());
    }
    else
    {
        mail( "aaa@bbb.coml.com", "Subject: Comments", $message, "From: $emailID\r\n $postedBy" );
    }
}
    else
{

echo '

<form action="contactus.php" method="POST" id="feedback" onsubmit="javascript:return validate("feedback","name","email","comments");">

                <p id="errorMsg">All fields are required</p>

                <label for="name" class="label" id="nameLabel">Your name: </label><input id="name" type="text" size="30"  name="name" class="field"/>
                <br /><br />
                <label for="email" class="label" id="emailLabel">Your Email id: </label><input id="email" type="text" size="30"  name="email" class="field"/>
                <br /><br />

                    <label for="comments" class="label" id="commentsLabel">Comments:</label>
                  <div id="commentsSection">
                    <textarea name="comments" id="comments" class="ui-corner-all" cols="9" rows="5" tabindex="140"></textarea>
                  </div>

            <p><input type="submit" value="Submit" id="submit"/> <input type="reset" /></p>

        </form>';
}

    mysql_close($con);
?>
</code>```

Everrything's is working fine but I can't validate the form using javascript.

答:
You don't need to specify javascriptin onsubmit:

```<code>onsubmit="javascript:return validate("feedback","name","email","comments")"
</code>```

instead do this:

```<code>onsubmit="return validate("feedback","name","email","comments")"
</code>```

and I hope you are putting proper escape charaters for the strings. Use this instead:

```<code>onsubmit="return validate(\"feedback\",\"name\",\"email\",\"comments\")"
</code>```

Title: Calling javascript form php

Body:
I am having a form inside a php script. I am doing the validation using javascript.

<?php

$con = mysql_connect("servername","login","passsword");
if (!$con)
    {
        die('Could not connect: ' . mysql_error());
    }

mysql_select_db("dbadminatms", $con);

if (isset($_POST['email']) && isset($_POST['name']) && isset($_POST['comments']))
{
    $sql="INSERT INTO feedback_comments (posted_by, email, comments_text, comment_date)
        VALUES
    ('$_POST[name]','$_POST[email]','$_POST[comments]',NOW())";
    $emailID = $_POST['email'];
    $postedBy = $_POST['name'];
    $message = $_POST['comments'];

    if (!mysql_query($sql,$con))
    {
        die('Error: ' . mysql_error());
    }
    else
    {
        mail( "aaa@bbb.coml.com", "Subject: Comments", $message, "From: $emailID\r\n $postedBy" );
    }
}
    else
{

echo '

<form action="contactus.php" method="POST" id="feedback" onsubmit="javascript:return validate("feedback","name","email","comments");">

All fields are required

                Your name: <input id="name" type="text" size="30"  name="name" class="field"/>

                Your Email id: <input id="email" type="text" size="30"  name="email" class="field"/>

                    Comments:

                    <textarea name="comments" id="comments" class="ui-corner-all" cols="9" rows="5" tabindex="140"></textarea>

<input type="submit" value="Submit" id="submit"/> <input type="reset" />

        </form>';
}

    mysql_close($con);
?>

Everrything's is working fine but I can't validate the form using javascript.

Body:
You don't need to specify javascriptin onsubmit:

onsubmit="javascript:return validate("feedback","name","email","comments")"

instead do this:

onsubmit="return validate("feedback","name","email","comments")"

and I hope you are putting proper escape charaters for the strings. Use this instead:

onsubmit="return validate(\"feedback\",\"name\",\"email\",\"comments\")"


问:
Create public facing SugarCRM form to create contact
How can I create a publicly facing SugarCRM form in order to enter a contact into the SugarCRM database?

Do I need to create my own form and create queries to insert the fields into the appropriate customer tables or is there a stream lined way of doing this?

答:
you will need to create your custom form. Then when form submit, send REST/SOAP call(set_entry) to create new contact.

You need to know that web-to-lead for only create lead record(campaign is also required int that case).


问:
always Session Expired in production server asp.net; but working fine in test environment
always Session Expired in production server asp.net; but working fine in test environment,
when i try to login my application i got session expired message, after 3 or 4 attempts i am able to login, but application works fine in test server</p>

答:
add this line for your WebConfig file </p>

```<code> <system.web>
<sessionState timeout="60"></sessionState>
 </system.web>
</code>```

Body:
add this line for your WebConfig file

 <system.web>
<sessionState timeout="60"></sessionState>
 </system.web>


问:
Assign a class based on matching text
I have a list of albums as an array in my component ts. In my HTML I display each of the albums using an ngFor. Each of these items have a default class of "album_item"

After a query, I have a service that returns the name of an album. If the returned album name from the service matches one of the album names in the components albums array, I want to add a 'highlighted' class to show which album has matched (such as "album_item_highlight")

So far I have my html display the list of albums from the array, I have the correct default class showing and I can correctly return an album from a service.

I'd appreciate help with assigning another class when an item matches.

export class AlbumsComponent implements OnInit {

  albums = ["Album One", "Album Two", "Album Three"];

  returnedAlbum: string;

  matchingAlbum = true;

  constructor(
    public albumsService: AlbumsService,
  ) { }

  ngOnInit() {

    // My service is returning one album and storing it as 'myAlbum'
    this.returnedAlbum = this.ablumsService.myAlbum;
  }

}
```

<pre class="lang-html prettyprint-override"><code><div class="album-wrapper">
  <div class="label">Albums</div>
  <div *ngFor="let album of albums">
    <div class="album_item" [class.selectedAlbum]="matchingAlbum"> {{ album }} </div>
  </div>
</div>
</code>```

答:
You can use [ngClass]:

```<code>[ngClass]="{'someOtherClass': matchingAlbum}"
</code>```

Doc Ref:  https://angular.io/api/common/NgClass

Title: Assign a class based on matching text

Body:
I have a list of albums as an array in my component ts. In my HTML I display each of the albums using an ngFor. Each of these items have a default class of "album_item"

After a query, I have a service that returns the name of an album. If the returned album name from the service matches one of the album names in the components albums array, I want to add a 'highlighted' class to show which album has matched (such as "album_item_highlight")

So far I have my html display the list of albums from the array, I have the correct default class showing and I can correctly return an album from a service.

I'd appreciate help with assigning another class when an item matches.

export class AlbumsComponent implements OnInit {

  albums = ["Album One", "Album Two", "Album Three"];

  returnedAlbum: string;

  matchingAlbum = true;

  constructor(
    public albumsService: AlbumsService,
  ) { }

  ngOnInit() {

    // My service is returning one album and storing it as 'myAlbum'
    this.returnedAlbum = this.ablumsService.myAlbum;
  }

}

Albums

 {{ album }}

Body:
You can use [ngClass]:

[ngClass]="{'someOtherClass': matchingAlbum}"

Doc Ref:  https://angular.io/api/common/NgClass