Code Duplication    Length = 32-57 lines in 2 locations

class/adodb.php 1 location

@@ 720-751 (lines=32) @@
717
				where status & 2048 = 2048
718
					and id = object_id('sgqyjbqk')
719
				 */
720
				if ($this->IsDbSybase()) {
721
					$rs = $this->PExecuteGenSql(array(
722
						'select' => array(
723
							'name' => 'a.name',
724
							'keycnt' => 'a.keycnt',
725
							'k1' => "index_col('$table', indid, 1)",
726
							'k2' => "index_col('$table', indid, 2)",
727
							'k3' => "index_col('$table', indid, 3)",
728
							),
729
						'from'	=> array(
730
							'a' => 'sysindexes',
731
							'b' => 'sysobjects',
732
						),
733
						'where' => array(
734
							'a.status & 2048 = 2048 ',
735
							"b.name = '$table'",
736
							"a.id = b.id"
737
							)
738
						));
739
					if (true == $rs && 0 < $rs->RowCount()) {
740
						// Got
741
						$ar = array($rs->fields['k1']);
742
						if (!empty($rs->fields['k2']))
743
							$ar[] = $rs->fields['k2'];
744
						if (!empty($rs->fields['k3']))
745
							$ar[] = $rs->fields['k3'];
746
					}
747
					else {
748
						// Table have no primary key
749
						$ar = '';
750
					}
751
				}
752
			}
753
754
			// Convert columns to native case

src/Fwlib/Bridge/Adodb.php 1 location

@@ 809-865 (lines=57) @@
806
    {
807
        if (!isset($this->metaPrimaryKey[$table]) || (true == $forcenew)) {
808
            // @codeCoverageIgnoreStart
809
            if ($this->isDbSybase()) {
810
                /**
811
                 * MetaPrimaryKey() in ADOdb has error(till v5.18), find PK
812
                 * manually.
813
                 *
814
                 * @link http://topic.csdn.net/t/20030117/17/1369396.html
815
                 *
816
                 * SELECT name, keycnt,
817
                 *      index_col(tableName, indid, 1),    -- 1st PK col
818
                 *      index_col(tableName, indid, 2)     -- 2nd PK col if has
819
                 * FROM sysindexes
820
                 * WHERE status & 2048 = 2048
821
                 *      AND id = object_id(tableName)
822
                 *
823
                 * keycnt is column count in PK. if PK index is not cursor
824
                 * index(by 0x10 bit in status), its keycnt - 1.
825
                 *
826
                 * Test pass for PK include 2 columns.
827
                 */
828
                $rs = $this->execute(
829
                    [
830
                        'SELECT' => [
831
                            'name'   => 'a.name',
832
                            'keycnt' => 'a.keycnt',
833
                            'k1'     => "index_col('$table', indid, 1)",
834
                            'k2'     => "index_col('$table', indid, 2)",
835
                            'k3'     => "index_col('$table', indid, 3)",
836
                        ],
837
                        'FROM'   => [
838
                            'a' => 'sysindexes',
839
                            'b' => 'sysobjects',
840
                        ],
841
                        'WHERE'  => [
842
                            'a.status & 2048 = 2048 ',
843
                            "b.name = '$table'",
844
                            "a.id = b.id",
845
                        ],
846
                    ]
847
                );
848
                if (true == $rs && 0 < $rs->RowCount()) {
849
                    // Got
850
                    $ar = [$rs->fields['k1']];
851
                    if (!empty($rs->fields['k2'])) {
852
                        $ar[] = $rs->fields['k2'];
853
                    }
854
                    if (!empty($rs->fields['k3'])) {
855
                        $ar[] = $rs->fields['k3'];
856
                    }
857
                } else {
858
                    // Table have no primary key
859
                    $ar = '';
860
                }
861
862
            } else {
863
                // Find using ADOdb first
864
                $ar = $this->conn->MetaPrimaryKeys($table);
865
            }
866
            // @codeCoverageIgnoreEnd
867
868