Esempio n. 1
0
 /**
  *
  * @param RedBean_OODBBean $parent
  * @return array $childObjects
  */
 public function children(RedBean_OODBBean $parent)
 {
     $idfield = $this->writer->getIDField($parent->getMeta("type"));
     try {
         $ids = $this->adapter->getCol("SELECT `" . $idfield . "` FROM\n\t\t\t`" . $parent->getMeta("type") . "`\n\t\t\tWHERE `" . $this->property . "` = " . intval($parent->{$idfield}) . "\n\t\t");
     } catch (RedBean_Exception_SQL $e) {
         return array();
     }
     return $this->oodb->batch($parent->getMeta("type"), $ids);
 }
Esempio n. 2
0
 /**
  * Gets related beans of type $type for bean $bean
  * @param RedBean_OODBBean $bean
  * @param string $type
  * @return array $ids
  */
 public function related(RedBean_OODBBean $bean, $type)
 {
     $table = $this->getTable(array($bean->getMeta("type"), $type));
     $idfield = $this->writer->getIDField($bean->getMeta("type"));
     if ($type == $bean->getMeta("type")) {
         // echo "<b>CROSS</b>";
         $type .= "2";
         $cross = 1;
     } else {
         $cross = 0;
     }
     $targetproperty = $type . "_id";
     $property = $bean->getMeta("type") . "_id";
     $sqlFetchKeys = " SELECT " . $this->adapter->escape($targetproperty) . " FROM `{$table}` WHERE " . $this->adapter->escape($property) . "\n\t\t\t= " . $this->adapter->escape($bean->{$idfield});
     if ($cross) {
         $sqlFetchKeys .= " UNION SELECT " . $this->adapter->escape($property) . " \n\t\t\tFROM `{$table}`\n\t\t\tWHERE " . $this->adapter->escape($targetproperty) . " = " . $this->adapter->escape($bean->{$idfield});
     }
     try {
         return $this->adapter->getCol($sqlFetchKeys);
     } catch (RedBean_Exception_SQL $e) {
         if ($e->getSQLState() != "42S02" && $e->getSQLState() != "42S22") {
             throw $e;
         }
         return array();
     }
 }
Esempio n. 3
0
 /**
  * @see RedBean_QueryWriter::getTables();
  */
 public function getTables()
 {
     if ($this->prefix) {
         return $this->adapter->getCol("SELECT name FROM sqlite_master\n\t\t\tWHERE type='table' AND name!='sqlite_sequence' AND name LIKE '" . $this->prefix . "%';");
     } else {
         return $this->adapter->getCol("SELECT name FROM sqlite_master\n\t\t\tWHERE type='table' AND name!='sqlite_sequence';");
     }
 }
Esempio n. 4
0
 /**
  * @see RedBean_QueryWriter::getTables
  */
 public function getTables()
 {
     if ($this->prefix) {
         return $this->adapter->getCol('show tables like \'' . $this->prefix . '%\'');
     } else {
         return $this->adapter->getCol('show tables');
     }
 }
 /**
  * @see RedBean_QueryWriter::getTables
  */
 public function getTables()
 {
     if ($this->prefix) {
         return $this->adapter->getCol("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_name LIKE '" . $this->prefix . "%'");
     } else {
         return $this->adapter->getCol("SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'");
     }
 }
Esempio n. 6
0
 /**
  * @see RedBean_QueryWriter::getTables
  */
 public function getTables()
 {
     if ($this->prefix) {
         $rows = $this->adapter->getCol("SELECT class_name FROM db_class WHERE is_system_class = 'NO' AND class_name LIKE '" . $this->prefix . "%';");
     } else {
         $rows = $this->adapter->getCol("SELECT class_name FROM db_class WHERE is_system_class = 'NO';");
     }
     return $rows;
 }
Esempio n. 7
0
 /**
  * Returns all tables in the database
  *
  * @return array $tables tables
  */
 public function getTables()
 {
     return $this->adapter->getCol("SELECT name FROM sqlite_master\n\t\t\tWHERE type='table' AND name!='sqlite_sequence';");
 }
Esempio n. 8
0
 /**
  * @see RedBean_QueryWriter::getTables
  */
 public function getTables()
 {
     $rows = $this->adapter->getCol("SELECT class_name FROM db_class WHERE is_system_class = 'NO';");
     return $rows;
 }
Esempio n. 9
0
 /**
  * Selects a record using a criterium.
  * Specify the select-column, the target table, the criterium column
  * and the criterium value. This method scans the specified table for
  * records having a criterium column with a value that matches the
  * specified value. For each record the select-column value will be
  * returned, most likely this will be a primary key column like ID.
  * If $withUnion equals true the method will also return the $column
  * values for each entry that has a matching select-column. This is
  * handy for cross-link tables like page_page.
  * @param string $select, the column to be selected
  * @param string $table, the table to select from
  * @param string $column, the column to compare the criteria value against
  * @param string $value, the criterium value to match against
  * @param boolean $withUnion (default is false)
  * @return array $mixedColumns
  */
 public function selectByCrit($select, $table, $column, $value, $withUnion = false)
 {
     $select = $this->noKW($this->adapter->escape($select));
     $table = $this->noKW($this->adapter->escape($table));
     $column = $this->noKW($this->adapter->escape($column));
     $value = $this->adapter->escape($value);
     $sql = "SELECT {$select} FROM {$table} WHERE {$column} = ? ";
     $values = array($value);
     if ($withUnion) {
         $sql .= " UNION SELECT {$column} FROM {$table} WHERE {$select} = ? ";
         $values[] = $value;
     }
     return $this->adapter->getCol($sql, $values);
 }
Esempio n. 10
0
 /**
  * @see RedBean_QueryWriter::getTables
  */
 public function getTables()
 {
     return $this->adapter->getCol('SELECT * FROM sys.Tables');
 }
Esempio n. 11
0
 /**
  * Returns all tables in the database.
  *
  * @return array $tables tables
  */
 public function getTables()
 {
     return $this->adapter->getCol("show tables");
 }
Esempio n. 12
0
 /**
  * Returns all tables in the database
  * @return array $tables
  */
 public function getTables()
 {
     return $this->adapter->getCol("SELECT name FROM sqlite_master WHERE type='table';");
 }