Walks down an ArithmeticPrimary that represents an AST node, thereby generating the appropriate SQL.

@param mixed $primary

@return string The SQL.
198249
public function walkArithmeticPrimary($primary)
    {
        if ($primary instanceof AST\SimpleArithmeticExpression) {
            return '(' . $this->walkSimpleArithmeticExpression($primary) . ')';
        }

        if ($primary instanceof AST\Node) {
            return $primary->dispatch($this);
        }

        return $this->walkEntityIdentificationVariable($primary);
    }
617013
protected function _getPrimary($id, $type = null)
    {
        $this->_setupPrimaryKey();

        if ($type === null) {
            $type = self::PRIMARY_TYPE_NUM;
        }

        $primaryArray = array();

        foreach ($this->_primary as $index => $primary) {
            switch ($this->_primaryAssignment[$index]) {
                case self::PRIMARY_ASSIGNMENT_SESSION_SAVE_PATH:
                    $value = $this->_sessionSavePath;
                    break;
                case self::PRIMARY_ASSIGNMENT_SESSION_NAME:
                    $value = $this->_sessionName;
                    break;
                case self::PRIMARY_ASSIGNMENT_SESSION_ID:
                    $value = (string) $id;
                    break;
                default:
                    $value = (string) $this->_primaryAssignment[$index];
                    break;
            }

            switch ((string) $type) {
                case self::PRIMARY_TYPE_PRIMARYNUM:
                    $primaryArray[$index] = $value;
                    break;
                case self::PRIMARY_TYPE_ASSOC:
                    $primaryArray[$primary] = $value;
                    break;
                case self::PRIMARY_TYPE_WHERECLAUSE:
                    $primaryArray[] = $this->getAdapter()->quoteIdentifier($primary, true) . ' = '
                                    . $this->getAdapter()->quote($value);
                    break;
                case self::PRIMARY_TYPE_NUM:
                default:
                    $primaryArray[] = $value;
                    break;
            }
        }

        return $primaryArray;
    }
566619
public function extractPrimaryKey($where) {
        if (is_array($where)) {
            $where = implode(' AND ', $where);
        }
        $pkColumns = $this->info(Zend_Db_Table_Abstract::PRIMARY);
        $pkValues = array();
        foreach ($pkColumns as $pk) {
            $regexp = '/(?:`?' . preg_quote($this->getName()) . '`?\.)?`?(?:' . preg_quote($pk) .
                ')`?\s?=\s?(?:(?P<q>[\'"])(?P<value>(?:(?!\k<q>).)*)\k<q>|(?P<rest>\w*))/';
            if (preg_match($regexp, $where, $matches)) {
                // Note: backreference "rest" is there to catch unquoted
                // values. (id = 100 instead of id = "100")
                if (!empty($matches['rest'])) {
                    $value = $matches['rest'];
                } else {
                    $value = $matches['value'];
                }
                $pkValues[$pk] = $value;
            }
        }
        return $pkValues;
    }
796066
public function getPrimaryKeyDDL(Table $table)
    {
        if ($table->hasPrimaryKey()) {

            $keys = $table->getPrimaryKey();

            //MySQL throws an 'Incorrect table definition; there can be only one auto column and it must be defined as a key'
            //if the primary key consists of multiple columns and if the first is not the autoIncrement one. So
            //this push the autoIncrement column to the first position if its not already.
            $autoIncrement = $table->getAutoIncrementPrimaryKey();
            if ($autoIncrement && $keys[0] != $autoIncrement) {
                $idx = array_search($autoIncrement, $keys);
                if ($idx !== false) {
                    unset($keys[$idx]);
                    array_unshift($keys, $autoIncrement);
                }
            }

            return 'PRIMARY KEY (' . $this->getColumnListDDL($keys) . ')';
        }
    }
100835
public function PrimaryKey($Table, $Database = NULL) {
      $Schema = $this->Fetch($Table, $Database);
      $PrimaryKeys = array();
      foreach ($Schema as $FieldName => $Properties) {
         if ($Properties->PrimaryKey === TRUE)
            $PrimaryKeys[] = $FieldName;
      }
      
      if (count($PrimaryKeys) == 0)
         return '';
      elseif (count($PrimaryKeys) == 1)
         return $PrimaryKeys[0];
      else
         return $PrimaryKeys;
   }
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();
    }
757862
private function _getData($primaryKey)
    {
        $table = $this->table;
        $db = $this->db;

        $query = "SELECT * FROM {$table->getTableName()} WHERE {$table->getPrimaryKey()} = $primaryKey";
        $sth = $table->getAdapter()->prepare($query);
        $sth->execute();

        return $sth->fetch($db::FETCH_ASSOC);
    }
156284
public function primary($pkeys) {
        if (empty($pkeys))
            return false;
        if (!is_array($pkeys))
            $pkeys = array($pkeys);
        // single pkey
        $this->increments = $pkeys[0];
        $this->pkeys = $pkeys;
        // drop duplicate pkey definition
        if (array_key_exists($this->increments,$this->columns))
            unset($this->columns[$this->increments]);
        // set flag on new fields
        foreach ($pkeys as $name)
            if(array_key_exists($name,$this->columns))
                $this->columns[$name]->pkey = true;
        // composite key
        if (count($pkeys) > 1) {
            $pkeys_quoted = array_map(array($this->db,'quotekey'), $pkeys);
            $pk_string = implode(', ', $pkeys_quoted);
            if (preg_match('/sqlite2?/', $this->db->driver())) {
                // rebuild table with new primary keys
                $this->rebuild_cmd['pkeys'] = $pkeys;
                return;
            } else {
                $table = $this->db->quotekey($this->name);
                $table_key = $this->db->quotekey($this->name.'_pkey');
                $cmd = array(
                    'odbc' =>
                        "CREATE INDEX $table_key ON $table ( $pk_string );",
                    'mysql' =>
                        "ALTER TABLE $table DROP PRIMARY KEY, ADD PRIMARY KEY ( $pk_string );",
                    'mssql|sybase|dblib|sqlsrv' => array(
                        "ALTER TABLE $table DROP CONSTRAINT PK_".$this->name."_ID;",
                        "ALTER TABLE $table ADD CONSTRAINT $table_key PRIMARY KEY ( $pk_string );",
                    ),
                    'pgsql' => array(
                        "ALTER TABLE $table DROP CONSTRAINT $table_key;",
                        "ALTER TABLE $table ADD CONSTRAINT $table_key PRIMARY KEY ( $pk_string );",
                    ),
                );
                $query = $this->findQuery($cmd);
                if (!is_array($query))
                    $query = array($query);
                foreach ($query as $q)
                    $this->queries[] = $q;
            }
        }
    }
727042
protected function query_insert_id ( $tableName, $primaryKey = null )
    {
        $sequenceName = $tableName;
        if ($primaryKey) {
            $sequenceName .= "_$primaryKey";
        }
        $sequenceName .= '_seq';

        $sql = "
            SELECT
                CURRVAL('%s')
                ";
        $args = array($sql, $sequenceName);
        $sql = $this->sql_printf($args);
        if (!($res = pg_query($this->conn, $sql))) {
            return 0;
        }
        $val = pg_fetch_row($res, 0);
        if ($val && isset($val[0])) {
            $val = $val[0];
        }

        pg_free_result($res);
        return $val;
    }
697407
public function id($column = 'id')
    {
        $this->int($column)->unsigned()->autoIncrement();

        return $this->primary($column);
    }
729302
public function getPrimaryKey() {
        if ($this->primaryKey === null) {
            $schema = $this->getSchema();

            $pk = [];
            foreach ($schema->getSchemaArray()['properties'] as $column => $property) {
                if (!empty($property['primary'])) {
                    $pk[] = $column;
                }
            }
            $this->primaryKey = $pk;
        }
        return $this->primaryKey;
    }
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;
	}
1344530
public function getPrimaryKeyDDL(Table $table)
    {
        if ($table->hasPrimaryKey() && !$table->hasAutoIncrementPrimaryKey()) {
            return 'PRIMARY KEY (' . $this->getColumnListDDL($table->getPrimaryKey()) . ')';
        }

        return '';
    }
1354234
private function preparePrimaryKey(array $primaryKey)
	{
		$result = array();
		foreach ($primaryKey as $key => $value) {
			$result[$key] = array(
				$this->getValueType($value) => $value
			);
		}
Debugger::barDump($result);
		return $result;
	}
255985
public function primaryKeyOf(string $table): string
    {
        $schema = $this->connection->getSchemaManager();
        return $schema->listTableDetails($table)->getPrimaryKeyColumns()[0];
    }
845447
public function getPrimaryKey(): ?Index {
		// if the table is not persistent so far, it is possible that it doesn't have a Primary Key
		$primaryKey = null;
		foreach ($this->getIndexes() as $index) {
			if ($index->getType() == IndexType::PRIMARY) {
				if (null === $this->primaryKey) {
					$primaryKey = $index;
				} else {
					throw new MetaRuntimeException('Duplicate primary key in table "' . $this->getName() . '"');
				}
			}
		}
		
		return $primaryKey;
	}
77229
protected function getNewPrimaryKey(Field $primaryKey = null, $defaultName = 'id')
    {
        $stub = $this->getStubContent('model-primary-key');

        $this->replacePrimaryKey($stub, $this->getPrimaryKeyName($primaryKey, $defaultName));

        if (!is_null($primaryKey) && !$primaryKey->isNumeric()) {
            $lines = explode("\n", $stub);
            $last = end($lines);
            $spaces = str_repeat(' ', $this->getIndent($last, 'p'));
            $stub .= PHP_EOL . $spaces . 'protected $keyType = \'string\';' . PHP_EOL;
            $stub .= $spaces . 'public $incrementing = false;' . PHP_EOL;
        }

        return $stub;
    }