src/Ease/SQL/Orm.php
public function saveToSQL($data = null, $searchForID = false)
    {
        $result = null;
        if (is_null($data)) {
            $data = $this->getData();
        }

        if (count($data) < 1) {
            $this->addStatusMessage('SaveToSQL: Missing data', 'error');
        } else {
            if ($searchForID) {
                if ($this->getMyKey($data)) {
                    $rowsFound = $this->getColumnsFromSQL($this->getKeyColumn(),
                        [$this->getKeyColumn() => $this->getMyKey($data)]);
                } else {
                    $rowsFound = $this->getColumnsFromSQL([$this->getKeyColumn()],
                        $data);
                    if (count($rowsFound)) {
                        if (is_numeric($rowsFound[0][$this->getKeyColumn()])) {
                            $data[$this->getKeyColumn()] = (int) $rowsFound[0][$this->getKeyColumn()];
                        } else {
                            $data[$this->getKeyColumn()] = $rowsFound[0][$this->getKeyColumn()];
                        }
                    }
                }

                if (count($rowsFound)) {
                    $result = $this->updateToSQL($data);
                } else {
                    $result = $this->insertToSQL($data);
                }
            } else {
                if (isset($data[$this->keyColumn]) && !is_null($data[$this->keyColumn])
                    && strlen($data[$this->keyColumn])) {
                    $result = $this->updateToSQL($data);
                } else {
                    $result = $this->insertToSQL($data);
                }
            }
        }

        if (!is_null($result)) {
            $this->setMyKey($result);
        }

        return $result;
    }
public function saveToSQL($data = null, $searchForID = false)
    {
        $result = null;
        if (is_null($data)) {
            $data = $this->getData();
        }

        if (count($data) < 1) {
            $this->addStatusMessage('SaveToSQL: Missing data', 'error');
        } else {
            if ($searchForID) {
                if ($this->getMyKey($data)) {
                    $rowsFound = $this->getColumnsFromSQL($this->getKeyColumn(),
                        [$this->getKeyColumn() => $this->getMyKey($data)]);
                } else {
                    $rowsFound = $this->getColumnsFromSQL([$this->getKeyColumn()],
                        $data);
                    if (count($rowsFound)) {
                        if (is_numeric($rowsFound[0][$this->getKeyColumn()])) {
                            $data[$this->getKeyColumn()] = (int) $rowsFound[0][$this->getKeyColumn()];
                        } else {
                            $data[$this->getKeyColumn()] = $rowsFound[0][$this->getKeyColumn()];
                        }
                    }
                }

                if (count($rowsFound)) {
                    $result = $this->updateToSQL($data);
                } else {
                    $result = $this->insertToSQL($data);
                }
            } else {
                if (isset($data[$this->keyColumn]) && !is_null($data[$this->keyColumn])
                    && strlen($data[$this->keyColumn])) {
                    $result = $this->updateToSQL($data);
                } else {
                    $result = $this->insertToSQL($data);
                }
            }
        }

        if (!is_null($result)) {
            $this->setMyKey($result);
        }

        return $result;
    }
Uloží pole dat do SQL. Pokud je $SearchForID 0 updatuje pokud ze nastaven  keyColumn.

@param array $data        asociativní pole dat
@param bool  $searchForID Zjistit zdali updatovat nebo insertovat

@return int ID záznamu nebo null v případě neůspěchu