Permalink
Browse files

Added is_array checks in some places.

  • Loading branch information...
1 parent 84a01e2 commit 78e16a31466f7b1a0efc63f962ee98b3dfe4e8fd @gabordemooij committed Oct 21, 2012
View
@@ -6,7 +6,7 @@ php:
before_script:
- echo 'yes' | sudo add-apt-repository ppa:cubrid/cubrid
- sudo apt-get update
- - sudo apt-get install cubrid
+ - sudo apt-get install cubrid-8.4.0
- /etc/profile.d/cubrid.sh
- sudo apt-get install cubrid-demodb
- sudo apt-get install php5-cubrid
@@ -177,7 +177,7 @@ public function getAssoc( $sql, $aValues = array() ) {
$assoc = array();
if ($rows) {
foreach($rows as $row) {
- if (count($row)>0) {
+ if (is_array($row) && count($row)>0) {
if (count($row)>1) {
$key = array_shift($row);
$value = array_shift($row);
@@ -199,7 +199,7 @@ protected function duplicate($bean,$trail=array(),$pid=false) {
$copy->id = 0;
$tables = $this->tables;
foreach($tables as $table) {
- if (count($this->filters) && !in_array($table,$this->filters)) continue;
+ if (is_array($this->filters) && count($this->filters) && !in_array($table,$this->filters)) continue;
if (strpos($table,'_')!==false || $table==$type) continue;
$owned = 'own'.ucfirst($table);
$shared = 'shared'.ucfirst($table);
View
@@ -331,7 +331,7 @@ public static function unassociate( $beans1, $beans2 , $fast=false) {
*/
public static function related( $bean, $type, $sql=null, $values=array()) {
$keys = self::$associationManager->related( $bean, $type );
- if (count($keys)==0) return array();
+ if (count($keys)==0 || !is_array($keys)) return array();
if (!$sql) return self::batch($type, $keys);
$rows = self::$writer->selectRecord( $type, array('id'=>$keys),array($sql,$values),false );
return self::$redbean->convertToBeans($type,$rows);
@@ -350,7 +350,7 @@ public static function related( $bean, $type, $sql=null, $values=array()) {
*/
public static function relatedOne( RedBean_OODBBean $bean, $type, $sql=null, $values=array() ) {
$beans = self::related($bean, $type, $sql, $values);
- if (count($beans)==0) return null;
+ if (count($beans)==0 || !is_array($beans)) return null;
return reset( $beans );
}
@@ -927,7 +927,7 @@ public static function getColumns($table) {
* @return string $slots
*/
public static function genSlots($array) {
- if (count($array)>0) {
+ if (is_array($array) && count($array)>0) {
$filler = array_fill(0,count($array),'?');
return implode(',',$filler);
}
View
@@ -535,7 +535,7 @@ private function processResidue($ownresidue) {
*/
private function processTrashcan($bean,$ownTrashcan) {
$myFieldLink = $bean->getMeta('type').'_id';
- if (count($ownTrashcan)>0) {
+ if (is_array($ownTrashcan) && count($ownTrashcan)>0) {
$first = reset($ownTrashcan);
if ($first instanceof RedBean_OODBBean) {
$alias = $bean->getMeta('sys.alias.'.$first->getMeta('type'));
View
@@ -217,7 +217,7 @@ public function export($meta = false, $parents = false, $onlyMe = false, $filter
}
}
elseif ($v instanceof RedBean_OODBBean) {
- if (count($filters) && !in_array(strtolower($v->getMeta('type')),$filters)) {
+ if (is_array($filters) && count($filters) && !in_array(strtolower($v->getMeta('type')),$filters)) {
continue;
}
$v = $v->export($meta,$parents,false,$filters);
@@ -119,7 +119,7 @@ public function export( $beans, $resetRecur=true ) {
}
if ($this->typeShield===true) {
- if (count($beans)>0) {
+ if (is_array($beans) && count($beans)>0) {
$firstBean = reset($beans);
$type = $firstBean->getMeta('type');
if (isset($this->recurTypeCheck[$type])){
@@ -248,7 +248,8 @@ public function selectRecord( $type, $conditions, $addSql=null, $delete=null, $i
$sql = $this->safeColumn($column);
$sql .= ' '.($inverse ? ' NOT ':'').' IN ( ';
//If its safe to not use bindings please do... (fixes SQLite PDO issue limit 256 bindings)
- if (count($conditions)===1
+ if (is_array($conditions)
+ && count($conditions)===1
&& isset($conditions['id'])
&& is_array($values)
&& preg_match('/^\d+$/',implode('',$values))) {
@@ -277,7 +278,7 @@ public function selectRecord( $type, $conditions, $addSql=null, $delete=null, $i
}
$sql = '';
- if (count($sqlConditions)>0) {
+ if (is_array($sqlConditions) && count($sqlConditions)>0) {
$sql = implode(' AND ',$sqlConditions);
$sql = " WHERE ( $sql ) ";
if ($addSql) $sql .= " AND $addSql ";
View
@@ -175,7 +175,7 @@ public function tagged( $beanType, $tagList ) {
if ($tagList!==false && !is_array($tagList)) $tags = explode( ",", (string)$tagList); else $tags=$tagList;
$collection = array();
$tags = $this->redbean->find('tag',array('title'=>$tags));
- if (count($tags)>0) {
+ if (is_array($tags) && count($tags)>0) {
$collectionKeys = $this->associationManager->related($tags,$beanType);
if ($collectionKeys) {
$collection = $this->redbean->batch($beanType,$collectionKeys);
@@ -44,12 +44,14 @@ public function run() {
information_schema.KEY_COLUMN_USAGE ke
WHERE
ke.referenced_table_name IS NOT NULL
+ AND ke.CONSTRAINT_SCHEMA="oodb"
ORDER BY
constraint_name;'));
$json = '[{"parent":"genre","child":"book_genre","constraint_name":"book_genre_ibfk_1"},{"parent":"book","child":"book_genre","constraint_name":"book_genre_ibfk_2"},{"parent":"cover","child":"book","constraint_name":"cons_fk_book_cover_id_id"},{"parent":"book","child":"page","constraint_name":"cons_fk_page_book_id_id"}]';
$j1 = json_decode($j,true);
$j2 = json_decode($json,true);
+
foreach($j1 as $jrow) {
$s = json_encode($jrow);
$found = 0;

0 comments on commit 78e16a3

Please sign in to comment.