src/Budkit/Datastore/Drivers/MySQLi/Table.php
public function insert($data = null, $updateIfExists = FALSE)
    {
        //1. Check if we have data and deal with it!
        if (!is_null($data)) {
            if (!$this->bindData($data)) {
                //we could not save the data
                return false;
            }
        }

        $primary = $this->keys("primary");
        $set = array();

        foreach ($this->schema as $field => $fieldObject) {

            //Skip the primary key for obvious reasons;
            if ($field === $primary->Field) continue;

            //Set the value pair for inserting
            $set[$field] = isset($fieldObject->Value) ? $fieldObject->Value : $fieldObject->Default;

            //Use Quotes in place of empty fields?
            if (empty($set[$field]) || (isset($fieldObject->Validate) && $fieldObject->Validate == 'string')) {
                $set[$field] = $this->dbo->Quote($set[$field]);
            }
        }

        if ($updateIfExists):
            $unique = $primary->Field;
            if (empty($unique)) {
                $updateIfExists = FALSE;
            }
        endif;

        //Insert into the database
        return $this->dbo->insert($this->getTableName(), $set, $updateIfExists, $unique);

    }
public function insert($data = null, $updateIfExists = FALSE)
    {
        //1. Check if we have data and deal with it!
        if (!is_null($data)) {
            if (!$this->bindData($data)) {
                //we could not save the data
                return false;
            }
        }

        $primary = $this->keys("primary");
        $set = array();

        foreach ($this->schema as $field => $fieldObject) {

            //Skip the primary key for obvious reasons;
            if ($field === $primary->Field) continue;

            //Set the value pair for inserting
            $set[$field] = isset($fieldObject->Value) ? $fieldObject->Value : $fieldObject->Default;

            //Use Quotes in place of empty fields?
            if (empty($set[$field]) || (isset($fieldObject->Validate) && $fieldObject->Validate == 'string')) {
                $set[$field] = $this->dbo->Quote($set[$field]);
            }
        }

        if ($updateIfExists):
            $unique = $primary->Field;
            if (empty($unique)) {
                $updateIfExists = FALSE;
            }
        endif;

        //Insert into the database
        return $this->dbo->insert($this->getTableName(), $set, $updateIfExists, $unique);

    }
public function insert ( $ data = null , $ updateIfExists = FALSE ) { //1. Check if we have data and deal with it! if ( ! is_null ( $ data ) ) { if ( ! $ this -> bindData ( $ data ) ) { //we could not save the data return false ; } } $ primary = $ this -> keys ( "primary" ) ; $ set = array ( ) ; foreach ( $ this -> schema as $ field => $ fieldObject ) { //Skip the primary key for obvious reasons; if ( $ field === $ primary -> Field ) continue ; //Set the value pair for inserting $ set [ $ field ] = isset ( $ fieldObject -> Value ) ? $ fieldObject -> Value : $ fieldObject -> Default ; //Use Quotes in place of empty fields? if ( empty ( $ set [ $ field ] ) || ( isset ( $ fieldObject -> Validate ) && $ fieldObject -> Validate == 'string' ) ) { $ set [ $ field ] = $ this -> dbo -> Quote ( $ set [ $ field ] ) ; } } if ( $ updateIfExists ) : $ unique = $ primary -> Field ; if ( empty ( $ unique ) ) { $ updateIfExists = FALSE ; } endif ; //Insert into the database return $ this -> dbo -> insert ( $ this -> getTableName ( ) , $ set , $ updateIfExists , $ unique ) ; }
Inserts a new record to the database

@param type $data
@return type
Inserts a new record to the database