Sets the primary key
@param string $pk
@return Table
546305
public function setPrimaryKey($pk) {
        if ($this->primaryKey === $pk) return $this;

        if ($this->primaryKey) {
            $this->dropPrimaryKey();
        }
        $this->newPrimaryKey = $pk;

        return $this;
    }
1078575
public function setPKValue(array $id)
    {
        if (count($id) !== count(static::$PKFieldName)) {
            throw new \InvalidArgumentException('Can`t set PK: passed values count not identical with primary key fields count');
        }

        if (count($id) === 1) {
            $this->{static::$PKFieldName[0]} = array_values($id)[0];

            return $this;
        }

        foreach ($id as $column => $value) {
            if ( ! self::isInPrimaryKey($column)) {
                throw new \InvalidArgumentException('Can`t set PK: Field `' . $column . '` is not a part of primary key.');
            }

            $this->$column = $value;
        }

        return $this;
    }
916842
public static function create(PermissionKey $pk)
    {
        $app = Application::getFacadeApplication();
        $db = $app->make(Connection::class);
        $db->executeQuery('insert into PermissionAccess (paIsInUse) values (0)');

        return static::getByID($db->lastInsertId(), $pk);
    }
1351603
function setPrimary( $table, $key ) {

        $this->primary[ $table ] = $key;

        // compound keys are never auto-generated,
        // so we can assume they are required
        if ( is_array( $key ) ) {

            foreach ( $key as $k ) {

                $this->setRequired( $table, $k );

            }

        }

        return $this;

    }
1303481
public function setPrimaryKey($value)
    {
        $pk = static::primaryKey()[0];
        if ($this->getIsNewRecord() || $pk != '_id') {
            $this->$pk = $value;
        } else {
            throw new InvalidCallException('Changing the primaryKey of an already saved record is not allowed.');
        }
    }
1120321
public function pkValue()
    {
        if ($args = func_get_args()) {
            !is_array($args[0]) || $args = array_shift($args);
            $args = array_values($args);
            foreach ($args as $key=>$arg)
                $this->{$this->_properties['primary_key'][$key]} = $arg;

            return $this;
        }

        $pk = array_intersect_key($this->_schema['values'],
            array_fill_keys($this->_properties['primary_key'], null));

        return count($pk)==0?null:(count($pk)==1?array_shift($pk):$pk);
    }
1332296
public function primaryKey($key = null)
    {
        deprecationWarning(
            get_called_class() . '::primaryKey() is deprecated. ' .
            'Use setPrimaryKey()/getPrimaryKey() instead.'
        );
        if ($key !== null) {
            $this->setPrimaryKey($key);
        }

        return $this->getPrimaryKey();
    }
401573
public function primary($columns, $name = null)
    {
        $columns = is_array($columns) ? $columns : [$columns];

        return $this->table->setPrimaryKey($columns, $name);
    }
40944
def __set_private_key(self, pk):
		
		self.__private_key = pk
		self.__public_key = pk.public_key()
1307385
public function delete($pk = NULL)
    {
        $this->action = self::API_ACTION_DELETE;
        $this->closeTransaction(200);
        $deleted = FALSE;
        $message = null;
        if (NULL !== $pk) {
            try {
                $this->con->beginTransaction();
                $this->hydrateModel($pk);
                if (NULL !== $this->model) {
                    if(method_exists('clearAllReferences', $this->model)) {
                        $this->model->clearAllReferences(true);
                    }
                    $this->model->delete($this->con);
                    $deleted = TRUE;
                }
            } catch (\Exception $e) {
                $context = [];
                if(null !== $e->getPrevious()) {
                    $context[] = $e->getPrevious()->getMessage();
                }
                Logger::log($e->getMessage(), LOG_CRIT, $context);

            }
        }

        return $this->json(new JsonResponse(null, $deleted, $deleted, 0, $message), ($deleted) ? 200 : 400);
    }
130471
public function setPrimaryKey(PrimaryKey $primaryKey)
    {
        foreach ($primaryKey->getColumnNames() as $columnName) {
            $this->getColumn($columnName)->setNotNull(true);
        }

        $this->primaryKey = $primaryKey;
    }
981790
public function setPrimaryKey( $column )
	{
		if( !strlen( trim( $column ) ) )
			throw new \InvalidArgumentException( 'Primary key column cannot be empty' );
		if( !in_array( $column, $this->columns ) )
			throw new \InvalidArgumentException( 'Column "'.$column.'" is not existing and can not be primary key' );
		$this->primaryKey = $column;
	}
74291
public function asOneToMany($table, $pk, $alias)
    {
        $this->relationProcessor->queue(__FUNCTION__, func_get_args());
        return $this;
    }
1350843
private static function generatePrimaryKey(array $pk, array $columns)
    {
        if (empty($pk)) {
            return '';
        }
        // Composite primary keys
        if (2 <= count($pk)) {
            $compositePk = implode(', ', $pk);
            return "    'PRIMARY KEY ($compositePk)',\n";
        }
        // Primary key not an auto-increment
        $flag = false;
        foreach ($columns as $column) {
            if ($column->autoIncrement) {
                $flag = true;
            }
        }
        if (false === $flag) {
            return sprintf("    'PRIMARY KEY (%s)',\n", $pk[0]);
        }
        return '';
    }
558547
public function getPrimaryKey ($db, $table)
	{
		
		// Get pk name
		
		return $this->db->query ('SHOW COLUMNS FROM ' . $db . '.' . $table . ' WHERE `Key` = \'PRI\'')->fetch (\PDO::FETCH_ASSOC);
		
	}
163877
public function setCpPrivateKey($cpPrivateKey = '')
    {
        $this->cpPrivateKey = $cpPrivateKey;
        $this->debug->info(__FUNCTION__, 'setCpPrivateKey: ' . json_encode($this->cpPrivateKey));

        return $this;
    }
1151224
public function getPrimaryKey($table)
	{
		$keys = $this->getTableKeys($table);
		$key  = false;

		if ($keys && count($keys) > 0)
		{
			foreach ($keys as $k)
			{
				if ($k->Key_name == 'PRIMARY')
				{
					$key = $k->Column_name;
				}
			}
		}

		return $key;
	}