mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merging fixes into the trunk.
Revision: [2618] Adding fix for Ticket #609 Revision: [2617] Added fix for Ticket #684 Revision: [2616] Adding patch from Ticket #649 Revision: [2615] Adding fix for Ticket #608 Revision: [2614] Additional fix for Ticket #584 Revision: [2613] Adding fix for Ticket #584 Revision: [2612] Added fix for undefined index notices Revision: [2609] Adding fix for Ticket #658 Revision: [2608] Adding fix for Ticket #635, and code formatting fixes in FormHelper Revision: [2607] Adding fix for Ticket #636 Revision: [2606] Adding fix to allow associations to be defined through non-associative arrays Revision: [2605] Adding fix for Ticket #672 Revision: [2604] Adding fix for Ticket #708 Revision: [2603] Adding fix for Ticket #687 Revision: [2602] Refactoring database drivers, and adding fix for Ticket #398 Revision: [2601] Merging change from model_php5.php Revision: [2600] Adding ODBC driver Revision: [2599] Adding fix for Ticket #702 Revision: [2598] Adding fix for Ticket #699 Revision: [2597] Fixing an issue in Model::set(), and moving limit() to DboSource Revision: [2595] Fixing unit test download URL in Bake Revision: [2594] Adding fix for Ticket #698 Revision: [2593] Adding fox for Ticket #231 Revision: [2592] Adding fix for Ticket #630, and updating MS SQL driver docstring Revision: [2577] Adding $alias property to enable future Oracle support Revision: [2568] Merging changes to bake from old sandboxes git-svn-id: https://svn.cakephp.org/repo/trunk/cake/1.x.x.x@2620 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
1707fd8582
commit
4a8c03ef1c
20 changed files with 1507 additions and 633 deletions
|
@ -6,4 +6,4 @@
|
|||
// +---------------------------------------------------------------------------------------------------+ //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
1.0.0.2560
|
||||
1.0.0.2620
|
|
@ -75,23 +75,26 @@ table {
|
|||
width: 100%;
|
||||
background-color: #fff;
|
||||
border: 1px solid #333;
|
||||
border-collapse: collapse;
|
||||
clear:both;
|
||||
margin: 0 0 2em 0;
|
||||
white-space: normal;
|
||||
}
|
||||
tbody {
|
||||
height: 400px;
|
||||
overflow: auto;
|
||||
}
|
||||
th {
|
||||
background-color: #ccc;
|
||||
border-top: 1px solid #fff;
|
||||
border-right: 1px solid #666;
|
||||
border-bottom: 1px solid #666;
|
||||
border: 1px solid #666;
|
||||
text-align: center;
|
||||
padding:3px;
|
||||
border-bottom: 1px solid #666;
|
||||
}
|
||||
table tr td {
|
||||
border-right: 1px solid #ccc;
|
||||
padding:4px 4px;
|
||||
vertical-align:top;
|
||||
text-align: center;
|
||||
border-bottom: 1px solid #666;
|
||||
}
|
||||
table tr.altRow td {
|
||||
background: #f4f4f4;
|
||||
|
|
|
@ -44,16 +44,6 @@ class AclNode extends AppModel
|
|||
|
||||
var $cacheQueries = false;
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
$this->setSource();
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
|
@ -262,7 +252,7 @@ class AclNode extends AppModel
|
|||
function _resolveID($id)
|
||||
{
|
||||
extract($this->__dataVars());
|
||||
$key = (is_string($id) ? 'alias' : $secondary_id);
|
||||
$key = (is_numeric($id) ? $secondary_id : 'alias');
|
||||
return array($this->name.'.'.$key => $id);
|
||||
}
|
||||
|
||||
|
@ -322,15 +312,6 @@ class AclNode extends AppModel
|
|||
$vars['class'] = ucwords($class);
|
||||
return $vars;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
*/
|
||||
function setSource()
|
||||
{
|
||||
$this->table = strtolower(get_class($this)) . "s";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
|
@ -76,14 +76,35 @@ class PagesController extends AppController{
|
|||
{
|
||||
$this->redirect('/');
|
||||
}
|
||||
|
||||
$path = func_get_args();
|
||||
|
||||
if (!count($path))
|
||||
{
|
||||
$this->redirect('/');
|
||||
}
|
||||
$this->set('page', $path[0]);
|
||||
$this->set('subpage', empty($path[1])? null: $path[1]);
|
||||
$this->set('title', ucfirst($path[count($path)-1]));
|
||||
|
||||
$count = count($path);
|
||||
$page = null;
|
||||
$subpage = null;
|
||||
$title = null;
|
||||
|
||||
if(!empty($path[0]))
|
||||
{
|
||||
$page = $path[0];
|
||||
}
|
||||
if(!empty($path[1]))
|
||||
{
|
||||
$subpage = $path[1];
|
||||
}
|
||||
if(!empty($path[$count-1]))
|
||||
{
|
||||
$title = ucfirst($path[$count-1]);
|
||||
}
|
||||
|
||||
$this->set('page', $page);
|
||||
$this->set('subpage', $subpage);
|
||||
$this->set('title', $title);
|
||||
$this->render(join('/', $path));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,6 +72,20 @@ class DboSource extends DataSource
|
|||
*/
|
||||
var $endQuote = null;
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
var $alias = 'AS ';
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
var $goofyLimit = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
|
@ -95,7 +109,7 @@ class DboSource extends DataSource
|
|||
$this->disconnect();
|
||||
if ($config != null)
|
||||
{
|
||||
$this->config = am($this->config, $config);
|
||||
$this->config = am($this->_baseConfig, $config);
|
||||
}
|
||||
return $this->connect();
|
||||
}
|
||||
|
@ -326,7 +340,7 @@ class DboSource extends DataSource
|
|||
* @param boolean $cache Enables returning/storing cached query results
|
||||
* @return array Array of resultset rows, or false if no rows matched
|
||||
*/
|
||||
function fetchAll ($sql, $cache = true)
|
||||
function fetchAll ($sql, $cache = true, $modelName = null)
|
||||
{
|
||||
if ($cache && isset($this->_queryCache[$sql]))
|
||||
{
|
||||
|
@ -409,8 +423,8 @@ class DboSource extends DataSource
|
|||
{
|
||||
$text = 'query';
|
||||
}
|
||||
print("<table border=\"1\">\n<tr><th colspan=\"7\">{$this->_queriesCnt} {$text} took {$this->_queriesTime} ms</th></tr>\n");
|
||||
print("<tr><td>Nr</td><td>Query</td><td>Error</td><td>Affected</td><td>Num. rows</td><td>Took (ms)</td></tr>\n");
|
||||
print("<table border=\"0\">\n<caption>{$this->_queriesCnt} {$text} took {$this->_queriesTime} ms</caption>\n");
|
||||
print("<thead>\n<tr><th>Nr</th><th>Query</th><th>Error</th><th>Affected</th><th>Num. rows</th><th>Took (ms)</th></tr>\n</thead>\n<tbody>\n");
|
||||
|
||||
foreach($log as $k => $i)
|
||||
{
|
||||
|
@ -580,7 +594,7 @@ class DboSource extends DataSource
|
|||
|
||||
// Build final query SQL
|
||||
$query = $this->generateAssociationQuery($model, $null, null, null, null, $queryData, false, $null);
|
||||
$resultSet = $this->fetchAll($query, $model->cacheQueries);
|
||||
$resultSet = $this->fetchAll($query, $model->cacheQueries, $model->name );
|
||||
$filtered = $this->__filterResults($resultSet, $model);
|
||||
|
||||
if ($model->recursive > 0)
|
||||
|
@ -613,7 +627,7 @@ class DboSource extends DataSource
|
|||
}
|
||||
if (isset($db) && $db != null)
|
||||
{
|
||||
$db->queryAssociation($model, $linkModel, $type, $assoc, $assocData, $array, true, $resultSet, $model->recursive);
|
||||
$db->queryAssociation($model, $linkModel, $type, $assoc, $assocData, $array, true, $resultSet, $model->recursive - 1);
|
||||
unset($db);
|
||||
}
|
||||
}
|
||||
|
@ -628,12 +642,14 @@ class DboSource extends DataSource
|
|||
return $resultSet;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Private method
|
||||
* Enter description here...
|
||||
*
|
||||
* @param unknown_type $linkModel
|
||||
* @param Model $model
|
||||
* @return array
|
||||
* @param unknown_type $results
|
||||
* @param unknown_type $model
|
||||
* @param unknown_type $filtered
|
||||
* @return unknown
|
||||
*/
|
||||
function __filterResults(&$results, &$model, $filtered = array())
|
||||
{
|
||||
|
@ -706,7 +722,7 @@ class DboSource extends DataSource
|
|||
{
|
||||
$row =& $resultSet[$i];
|
||||
$q = $this->insertQueryData($query, $resultSet, $association, $assocData, $model, $linkModel, $i);
|
||||
$fetch = $this->fetchAll($q, $model->cacheQueries);
|
||||
$fetch = $this->fetchAll($q, $model->cacheQueries, $model->name);
|
||||
|
||||
if (!empty($fetch) && is_array($fetch))
|
||||
{
|
||||
|
@ -726,10 +742,23 @@ class DboSource extends DataSource
|
|||
}
|
||||
$this->__mergeAssociation($resultSet[$i], $fetch, $association, $type);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tempArray[0][$association] = false;
|
||||
$this->__mergeAssociation($resultSet[$i], $tempArray, $association, $type);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @param unknown_type $data
|
||||
* @param unknown_type $merge
|
||||
* @param unknown_type $association
|
||||
* @param unknown_type $type
|
||||
*/
|
||||
function __mergeAssociation(&$data, $merge, $association, $type)
|
||||
{
|
||||
if (isset($merge[0]) && !isset($merge[0][$association]))
|
||||
|
@ -759,6 +788,12 @@ class DboSource extends DataSource
|
|||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if($merge[0][$association] === false)
|
||||
{
|
||||
$data[$association] = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($merge as $i => $row)
|
||||
{
|
||||
|
@ -775,6 +810,7 @@ class DboSource extends DataSource
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
|
@ -798,8 +834,8 @@ class DboSource extends DataSource
|
|||
|
||||
$sql = 'SELECT ' . join(', ', $this->fields($model, $model->name, $queryData['fields'])). ', ';
|
||||
$sql .= join(', ', $this->fields($linkModel, $alias, ''));
|
||||
$sql .= ' FROM '.$this->name($model->table).' AS ' . $this->name($model->name);
|
||||
$sql .= ' LEFT JOIN '.$this->name($linkModel->table).' AS ' . $this->name($alias);
|
||||
$sql .= ' FROM '.$this->name($model->table).' '.$this->alias.$this->name($model->name);
|
||||
$sql .= ' LEFT JOIN '.$this->name($linkModel->table).' '.$this->alias.$this->name($alias);
|
||||
$sql .= ' ON ';
|
||||
$sql .= $this->name($model->name).'.'.$this->name($assocData['foreignKey']);
|
||||
$sql .= ' = '.$this->name($alias).'.'.$this->name($linkModel->primaryKey);
|
||||
|
@ -868,13 +904,22 @@ class DboSource extends DataSource
|
|||
{
|
||||
$joinFields = null;
|
||||
}
|
||||
|
||||
// Generates primary query
|
||||
$sql = 'SELECT ' . join(', ', $this->fields($model, $model->name, $queryData['fields'])) .$joinFields. ' FROM ';
|
||||
$sql .= $this->name($model->table).' AS ';
|
||||
$sql = 'SELECT ';
|
||||
if ($this->goofyLimit)
|
||||
{
|
||||
$sql .= $this->limit($queryData['limit']);
|
||||
}
|
||||
$sql .= ' ' . join(', ', $this->fields($model, $model->name, $queryData['fields'])) .$joinFields. ' FROM ';
|
||||
$sql .= $this->name($model->table).' '.$this->alias;
|
||||
$sql .= $this->name($model->name).' ' . join(' ', $queryData['joins']).' ';
|
||||
$sql .= $this->conditions($queryData['conditions']).' '.$this->order($queryData['order']);
|
||||
if (!$this->goofyLimit)
|
||||
{
|
||||
$sql .= ' '.$this->limit($queryData['limit']);
|
||||
}
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
||||
|
@ -897,8 +942,18 @@ class DboSource extends DataSource
|
|||
{
|
||||
$assocData['fields'] = '';
|
||||
}
|
||||
$sql = 'SELECT '.join(', ', $this->fields($linkModel, $alias, $assocData['fields']));
|
||||
$sql .= ' FROM '.$this->name($linkModel->table).' AS '.$this->name($alias).' ';
|
||||
$limit = '';
|
||||
if (isset($queryData['limit']) && !empty($queryData['limit']))
|
||||
{
|
||||
$limit = $this->limit($queryData['limit']);
|
||||
}
|
||||
$sql = 'SELECT ';
|
||||
if ($this->goofyLimit)
|
||||
{
|
||||
$sql .= $limit;
|
||||
}
|
||||
$sql .= ' '.join(', ', $this->fields($linkModel, $alias, $assocData['fields']));
|
||||
$sql .= ' FROM '.$this->name($linkModel->table).' '.$this->alias.$this->name($alias).' ';
|
||||
|
||||
$conditions = $queryData['conditions'];
|
||||
$condition = $this->name($alias).'.'.$this->name($assocData['foreignKey']);
|
||||
|
@ -920,7 +975,11 @@ class DboSource extends DataSource
|
|||
$conditions .= $cond;
|
||||
}
|
||||
$sql .= $this->conditions($conditions) . $this->order($queryData['order']);
|
||||
$sql .= $this->limit($queryData['limit']);
|
||||
|
||||
if (!$this->goofyLimit)
|
||||
{
|
||||
$sql .= $limit;
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
else
|
||||
|
@ -939,7 +998,7 @@ class DboSource extends DataSource
|
|||
$this->__assocJoins = null;
|
||||
}
|
||||
$sql = ' LEFT JOIN '.$this->name($linkModel->table);
|
||||
$sql .= ' AS '.$this->name($alias).' ON '.$this->name($alias).'.';
|
||||
$sql .= ' '.$this->alias.$this->name($alias).' ON '.$this->name($alias).'.';
|
||||
$sql .= $this->name($assocData['foreignKey']).'='.$model->escapeField($model->primaryKey);
|
||||
|
||||
if ($assocData['order'] != null)
|
||||
|
@ -969,12 +1028,23 @@ class DboSource extends DataSource
|
|||
case 'belongsTo':
|
||||
if ($external)
|
||||
{
|
||||
$limit = '';
|
||||
if (isset($assocData['limit']))
|
||||
{
|
||||
$limit = $this->limit($assocData['limit']);
|
||||
}
|
||||
if(!isset($assocData['fields']))
|
||||
{
|
||||
$assocData['fields'] = '';
|
||||
}
|
||||
$sql = 'SELECT '.join(', ', $this->fields($linkModel, $alias, $assocData['fields']));
|
||||
$sql .= ' FROM '.$this->name($linkModel->table).' AS '.$this->name($alias).' ';
|
||||
|
||||
$sql = 'SELECT ';
|
||||
if ($this->goofyLimit)
|
||||
{
|
||||
$sql .= $limit;
|
||||
}
|
||||
$sql .= ' '.join(', ', $this->fields($linkModel, $alias, $assocData['fields']));
|
||||
$sql .= ' FROM '.$this->name($linkModel->table).' '.$this->alias.$this->name($alias).' ';
|
||||
|
||||
$conditions = $assocData['conditions'];
|
||||
|
||||
|
@ -994,9 +1064,9 @@ class DboSource extends DataSource
|
|||
$conditions .= $condition;
|
||||
}
|
||||
$sql .= $this->conditions($conditions) . $this->order($assocData['order']);
|
||||
if (isset($assocData['limit']))
|
||||
if (!$this->goofyLimit)
|
||||
{
|
||||
$sql .= $this->limit($assocData['limit']);
|
||||
$sql .= $limit;
|
||||
}
|
||||
return $sql;
|
||||
}
|
||||
|
@ -1016,7 +1086,7 @@ class DboSource extends DataSource
|
|||
$this->__assocJoins = null;
|
||||
}
|
||||
$sql = ' LEFT JOIN '.$this->name($linkModel->table);
|
||||
$sql .= ' AS ' . $this->name($alias) . ' ON ';
|
||||
$sql .= ' '.$this->alias . $this->name($alias) . ' ON ';
|
||||
$sql .= $this->name($model->name).'.'.$this->name($assocData['foreignKey']);
|
||||
$sql .= '='.$this->name($alias).'.'.$this->name($linkModel->primaryKey);
|
||||
|
||||
|
@ -1046,9 +1116,20 @@ class DboSource extends DataSource
|
|||
}
|
||||
else
|
||||
{
|
||||
$limit = '';
|
||||
if (isset($assocData['limit']))
|
||||
{
|
||||
$limit = $this->limit($assocData['limit']);
|
||||
}
|
||||
|
||||
$conditions = $assocData['conditions'];
|
||||
$sql = 'SELECT '.join(', ', $this->fields($linkModel, $alias, $assocData['fields']));
|
||||
$sql .= ' FROM '.$this->name($linkModel->table).' AS '. $this->name($alias);
|
||||
$sql = 'SELECT ';
|
||||
if ($this->goofyLimit)
|
||||
{
|
||||
$sql .= $limit;
|
||||
}
|
||||
$sql .= ' '.join(', ', $this->fields($linkModel, $alias, $assocData['fields']));
|
||||
$sql .= ' FROM '.$this->name($linkModel->table).' '.$this->alias. $this->name($alias);
|
||||
|
||||
if (is_array($conditions))
|
||||
{
|
||||
|
@ -1068,9 +1149,9 @@ class DboSource extends DataSource
|
|||
$sql .= $this->conditions($conditions);
|
||||
$sql .= $this->order($assocData['order']);
|
||||
|
||||
if (isset($assocData['limit']))
|
||||
if (!$this->goofyLimit)
|
||||
{
|
||||
$sql .= $this->limit($assocData['limit']);
|
||||
$sql .= $limit;
|
||||
}
|
||||
}
|
||||
return $sql;
|
||||
|
@ -1084,8 +1165,18 @@ class DboSource extends DataSource
|
|||
{
|
||||
$joinTbl = $this->name($assocData['joinTable']);
|
||||
|
||||
$sql = 'SELECT '.join(', ', $this->fields($linkModel, $alias, $assocData['fields']));
|
||||
$sql .= ' FROM '.$this->name($linkModel->table).' AS '.$this->name($alias);
|
||||
$limit = '';
|
||||
if (isset($assocData['limit']))
|
||||
{
|
||||
$limit = $this->limit($assocData['limit']);
|
||||
}
|
||||
$sql = 'SELECT ';
|
||||
if ($this->goofyLimit)
|
||||
{
|
||||
$sql .= $limit;
|
||||
}
|
||||
$sql .= ' '.join(', ', $this->fields($linkModel, $alias, $assocData['fields']));
|
||||
$sql .= ' FROM '.$this->name($linkModel->table).' '.$this->alias.$this->name($alias);
|
||||
$sql .= ' JOIN '.$joinTbl.' ON '.$joinTbl;
|
||||
$sql .= '.'.$this->name($assocData['foreignKey']).'={$__cakeID__$}';
|
||||
$sql .= ' AND '.$joinTbl.'.'.$this->name($assocData['associationForeignKey']);
|
||||
|
@ -1093,9 +1184,9 @@ class DboSource extends DataSource
|
|||
|
||||
$sql .= $this->conditions($assocData['conditions']);
|
||||
$sql .= $this->order($assocData['order']);
|
||||
if (isset($assocData['limit']))
|
||||
if (!$this->goofyLimit)
|
||||
{
|
||||
$sql .= $this->limit($assocData['limit']);
|
||||
$sql .= $limit;
|
||||
}
|
||||
}
|
||||
return $sql;
|
||||
|
@ -1112,7 +1203,7 @@ class DboSource extends DataSource
|
|||
* @param array $values
|
||||
* @return array
|
||||
*/
|
||||
function update (&$model, $fields = null, $values = null)
|
||||
function update (&$model, $fields = array(), $values = array())
|
||||
{
|
||||
$updates = array();
|
||||
$combined = array_combine($fields, $values);
|
||||
|
@ -1413,13 +1504,30 @@ class DboSource extends DataSource
|
|||
return $out;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* To be overridden in subclasses.
|
||||
* Returns a limit statement in the correct format for the particular database.
|
||||
*
|
||||
* @param int $limit Limit of results returned
|
||||
* @param int $offset Offset from which to start results
|
||||
* @return string SQL limit/offset statement
|
||||
*/
|
||||
function limit ()
|
||||
function limit ($limit, $offset = null)
|
||||
{
|
||||
if ($limit)
|
||||
{
|
||||
$rt = '';
|
||||
if (!strpos(strtolower($limit), 'limit') || strpos(strtolower($limit), 'limit') === 0)
|
||||
{
|
||||
$rt = ' LIMIT';
|
||||
}
|
||||
if ($offset)
|
||||
{
|
||||
$rt .= ' ' . $offset. ',';
|
||||
}
|
||||
$rt .= ' ' . $limit;
|
||||
return $rt;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1565,7 +1673,7 @@ class DboSource extends DataSource
|
|||
*/
|
||||
function hasAny($table, $sql)
|
||||
{
|
||||
$out = $this->one("SELECT COUNT(*) AS count FROM {$table}".($sql? " WHERE {$sql}":""));
|
||||
$out = $this->one("SELECT COUNT(*) ".$this->alias."count FROM {$table}".($sql? " WHERE {$sql}":""));
|
||||
return is_array($out)? $out[0]['count']: false;
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,23 @@ class DboAdodb extends DboSource
|
|||
*/
|
||||
var $_adodb = null;
|
||||
|
||||
/**
|
||||
* Array translating ADOdb column MetaTypes to cake-supported metatypes
|
||||
*
|
||||
* @var array
|
||||
* @access private
|
||||
*/
|
||||
var $_adodb_column_types = array(
|
||||
'C' => 'string',
|
||||
'X' => 'text',
|
||||
'D' => 'date',
|
||||
'T' => 'timestamp',
|
||||
'L' => 'boolean',
|
||||
'N' => 'float',
|
||||
'I' => 'integer',
|
||||
'R' => 'integer', // denotes auto-increment or counter field
|
||||
'B' => 'binary');
|
||||
|
||||
/**
|
||||
* Connects to the database using options in the given configuration array.
|
||||
*
|
||||
|
@ -106,7 +123,7 @@ class DboAdodb extends DboSource
|
|||
* @param string $sql SQL statement
|
||||
* @return resource Result resource identifier
|
||||
*/
|
||||
function execute ($sql)
|
||||
function _execute ($sql)
|
||||
{
|
||||
return $this->_adodb->execute($sql);
|
||||
}
|
||||
|
@ -118,6 +135,10 @@ class DboAdodb extends DboSource
|
|||
*/
|
||||
function fetchRow ()
|
||||
{
|
||||
if($this->_result->EOF)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return $this->_result->FetchRow();
|
||||
}
|
||||
|
||||
|
@ -193,19 +214,26 @@ class DboAdodb extends DboSource
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns an array of the fields in given table name.
|
||||
* Returns an array of the fields in the table used by the given model.
|
||||
*
|
||||
* @param string $tableName Name of database table to inspect
|
||||
*
|
||||
* @param AppModel $model Model object
|
||||
* @return array Fields in table. Keys are name and type
|
||||
*/
|
||||
function fields ($tableName)
|
||||
function describe (&$model)
|
||||
{
|
||||
$data = $this->_adodb->MetaColumns($tableName);
|
||||
$cache = parent::describe($model);
|
||||
if ($cache != null)
|
||||
{
|
||||
return $cache;
|
||||
}
|
||||
$fields = false;
|
||||
|
||||
foreach ($data as $item)
|
||||
$fields[] = array('name'=>$item->name, 'type'=>$item->type);
|
||||
|
||||
$cols = $this->_adodb->MetaColumns($model->table);
|
||||
foreach ($cols as $column)
|
||||
{
|
||||
$fields[] = array('name'=>$column->name, 'type'=>$column->type);
|
||||
}
|
||||
$this->__cacheDescription($model->table, $fields);
|
||||
return $fields;
|
||||
}
|
||||
|
||||
|
@ -279,6 +307,87 @@ class DboAdodb extends DboSource
|
|||
// adodb doesn't allow us to get the correct limit string out of it
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts database-layer column types to basic types
|
||||
*
|
||||
* @param string $real Real database-layer column type (i.e. "varchar(255)")
|
||||
* @return string Abstract column type (i.e. "string")
|
||||
*/
|
||||
function column($real)
|
||||
{
|
||||
if ( isset( $this->_result ))
|
||||
{
|
||||
$adodb_metatyper = & $this->_result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$adodb_metatyper = & $this->_adodb->execute('Select 1');
|
||||
}
|
||||
$interpreted_type = $adodb_metatyper->MetaType($real);
|
||||
|
||||
if (!isset($this->_adodb_column_types[$interpreted_type]))
|
||||
{
|
||||
return 'text';
|
||||
}
|
||||
return $this->_adodb_column_types[ $interpreted_type ] ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a quoted and escaped string of $data for use in an SQL statement.
|
||||
*
|
||||
* @param string $data String to be prepared for use in an SQL statement
|
||||
* @param string $column_type The type of the column into which this data will be inserted
|
||||
* @param boolean $safe Whether or not numeric data should be handled automagically if no column data is provided
|
||||
* @return string Quoted and escaped data
|
||||
*/
|
||||
function value ($data, $column = null, $safe = false)
|
||||
{
|
||||
$parent = parent::value($data, $column, $safe);
|
||||
|
||||
if ($parent != null)
|
||||
{
|
||||
return $parent;
|
||||
}
|
||||
|
||||
if ($data === null)
|
||||
{
|
||||
return 'NULL';
|
||||
}
|
||||
|
||||
if($data == '')
|
||||
{
|
||||
return "''";
|
||||
}
|
||||
|
||||
if (ini_get('magic_quotes_gpc') == 1)
|
||||
{
|
||||
$data = stripslashes($data);
|
||||
}
|
||||
|
||||
return $this->_adodb->qstr( $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of all result rows for a given SQL query.
|
||||
* Returns false if no rows matched.
|
||||
*
|
||||
* @param string $sql SQL statement
|
||||
* @param boolean $cache Enables returning/storing cached query results
|
||||
* @param string $modelName Name of model for first array dimension of results
|
||||
* @return array Array of resultset rows, or false if no rows matched
|
||||
*/
|
||||
function fetchAll ($sql, $cache = true, $modelName = null)
|
||||
{
|
||||
$result = parent::fetchAll( $sql, $cache );
|
||||
if (!$result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
foreach($result as $key => $value)
|
||||
{
|
||||
$return[$key][$modelName] = $value;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -66,6 +66,13 @@ class DboMssql extends DboSource
|
|||
*/
|
||||
var $endQuote = "]";
|
||||
|
||||
/**
|
||||
* Enter description here...
|
||||
*
|
||||
* @var unknown_type
|
||||
*/
|
||||
var $goofyLimit = true;
|
||||
|
||||
/**
|
||||
* Base configuration settings for MS SQL driver
|
||||
*
|
||||
|
@ -196,7 +203,7 @@ class DboMssql extends DboSource
|
|||
|
||||
if (!$result || empty($result))
|
||||
{
|
||||
return null;
|
||||
return array();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -213,7 +220,7 @@ class DboMssql extends DboSource
|
|||
/**
|
||||
* Returns an array of the fields in given table name.
|
||||
*
|
||||
* @param string $tableName Name of database table to inspect
|
||||
* @param Model $model Model object to describe
|
||||
* @return array Fields in table. Keys are name and type
|
||||
*/
|
||||
function describe (&$model)
|
||||
|
@ -414,6 +421,28 @@ class DboMssql extends DboSource
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes Identity (primary key) column from update data before returning to parent
|
||||
*
|
||||
* @param Model $model
|
||||
* @param array $fields
|
||||
* @param array $values
|
||||
* @return array
|
||||
*/
|
||||
function update (&$model, $fields = array(), $values = array())
|
||||
{
|
||||
foreach ($fields as $i => $field)
|
||||
{
|
||||
if ($field == $model->primaryKey)
|
||||
{
|
||||
unset($fields[$i]);
|
||||
unset($values[$i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return parent::update($model, $fields, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a formatted error message from previous database operation.
|
||||
*
|
||||
|
@ -486,13 +515,9 @@ class DboMssql extends DboSource
|
|||
if ($limit)
|
||||
{
|
||||
$rt = '';
|
||||
if (!strpos(strtolower($limit), 'limit') || strpos(strtolower($limit), 'limit') === 0)
|
||||
if (!strpos(strtolower($limit), 'top') || strpos(strtolower($limit), 'top') === 0)
|
||||
{
|
||||
$rt = ' LIMIT';
|
||||
}
|
||||
if ($offset)
|
||||
{
|
||||
$rt .= ' ' . $offset. ',';
|
||||
$rt = ' TOP';
|
||||
}
|
||||
$rt .= ' ' . $limit;
|
||||
return $rt;
|
||||
|
@ -508,6 +533,16 @@ class DboMssql extends DboSource
|
|||
*/
|
||||
function column($real)
|
||||
{
|
||||
if (is_array($real))
|
||||
{
|
||||
$col = $real['name'];
|
||||
if (isset($real['limit']))
|
||||
{
|
||||
$col .= '('.$real['limit'].')';
|
||||
}
|
||||
return $col;
|
||||
}
|
||||
|
||||
$col = r(')', '', $real);
|
||||
$limit = null;
|
||||
@list($col, $limit) = explode('(', $col);
|
||||
|
|
|
@ -181,7 +181,7 @@ class DboMysql extends DboSource
|
|||
$result = mysql_list_tables($this->config['database'], $this->connection);
|
||||
if (!$result)
|
||||
{
|
||||
return null;
|
||||
return array();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -402,32 +402,6 @@ class DboMysql extends DboSource
|
|||
return mysql_insert_id($this->connection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a limit statement in the correct format for the particular database.
|
||||
*
|
||||
* @param int $limit Limit of results returned
|
||||
* @param int $offset Offset from which to start results
|
||||
* @return string SQL limit/offset statement
|
||||
*/
|
||||
function limit ($limit, $offset = null)
|
||||
{
|
||||
if ($limit)
|
||||
{
|
||||
$rt = '';
|
||||
if (!strpos(strtolower($limit), 'limit') || strpos(strtolower($limit), 'limit') === 0)
|
||||
{
|
||||
$rt = ' LIMIT';
|
||||
}
|
||||
if ($offset)
|
||||
{
|
||||
$rt .= ' ' . $offset. ',';
|
||||
}
|
||||
$rt .= ' ' . $limit;
|
||||
return $rt;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts database-layer column types to basic types
|
||||
*
|
||||
|
@ -436,6 +410,16 @@ class DboMysql extends DboSource
|
|||
*/
|
||||
function column($real)
|
||||
{
|
||||
if (is_array($real))
|
||||
{
|
||||
$col = $real['name'];
|
||||
if (isset($real['limit']))
|
||||
{
|
||||
$col .= '('.$real['limit'].')';
|
||||
}
|
||||
return $col;
|
||||
}
|
||||
|
||||
$col = r(')', '', $real);
|
||||
$limit = null;
|
||||
@list($col, $limit) = explode('(', $col);
|
||||
|
|
503
cake/libs/model/dbo/dbo_odbc.php
Normal file
503
cake/libs/model/dbo/dbo_odbc.php
Normal file
|
@ -0,0 +1,503 @@
|
|||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* ODBC for DBO
|
||||
*
|
||||
* Long description for file
|
||||
*
|
||||
* PHP versions 4 and 5
|
||||
*
|
||||
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
|
||||
* Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* 1785 E. Sahara Avenue, Suite 490-204
|
||||
* Las Vegas, Nevada 89104
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @filesource
|
||||
* @copyright Copyright (c) 2006, Cake Software Foundation, Inc.
|
||||
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
||||
* @package cake
|
||||
* @subpackage cake.cake.libs.model.dbo
|
||||
* @since CakePHP v 0.10.5.1790
|
||||
* @version $Revision$
|
||||
* @modifiedby $LastChangedBy$
|
||||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Include DBO.
|
||||
*/
|
||||
uses('model'.DS.'datasources'.DS.'dbo_source');
|
||||
|
||||
classÊDboOdbcÊextendsÊDboSource
|
||||
{
|
||||
|
||||
/**
|
||||
Ê*ÊEnterÊdescriptionÊhere...
|
||||
Ê*
|
||||
Ê*Ê@varÊunknown_type
|
||||
Ê*/
|
||||
ÊÊÊÊvarÊ$descriptionÊ=Ê"ODBCÊDBOÊDriver";
|
||||
|
||||
/**
|
||||
Ê*ÊEnterÊdescriptionÊhere...
|
||||
Ê*
|
||||
Ê*Ê@varÊunknown_type
|
||||
Ê*/
|
||||
ÊÊÊÊvarÊ$startQuoteÊ=Ê"`";
|
||||
|
||||
/**
|
||||
Ê*ÊEnterÊdescriptionÊhere...
|
||||
Ê*
|
||||
Ê*Ê@varÊunknown_type
|
||||
Ê*/
|
||||
ÊÊÊÊvarÊ$endQuoteÊ=Ê"`";
|
||||
|
||||
/**
|
||||
Ê*ÊEnterÊdescriptionÊhere...
|
||||
Ê*
|
||||
Ê*Ê@varÊunknown_type
|
||||
Ê*/
|
||||
ÊÊÊÊvarÊ$_baseConfigÊ=Êarray('persistent'Ê=>Êtrue,
|
||||
ÊÊÊÊ 'login'ÊÊÊÊÊÊ=>Ê'root',
|
||||
ÊÊ ÊÊ'password'ÊÊÊÊ=>Ê'',
|
||||
ÊÊÊÊ 'database'ÊÊÊÊ=>Ê'cake');
|
||||
|
||||
/**
|
||||
Ê*ÊEnterÊdescriptionÊhere...
|
||||
Ê*
|
||||
Ê*Ê@varÊunknown_type
|
||||
Ê*/
|
||||
ÊÊÊÊ
|
||||
ÊÊÊÊvarÊ$columnsÊ=Êarray();
|
||||
ÊÊÊÊ
|
||||
//ÊÊÊÊvarÊ$columnsÊ=Êarray('primary_key'Ê=>Êarray('name'Ê=>Ê'int(11)ÊDEFAULTÊNULLÊauto_increment'),
|
||||
//ÊÊÊÊ'string'ÊÊÊÊÊÊ=>Êarray('name'Ê=>Ê'varchar',Ê'limit'Ê=>Ê'255'),
|
||||
//ÊÊÊÊ'text'ÊÊÊÊÊÊÊÊ=>Êarray('name'Ê=>Ê'text'),
|
||||
//ÊÊÊÊ'integer'ÊÊÊÊÊ=>Êarray('name'Ê=>Ê'int',Ê'limit'Ê=>Ê'11'),
|
||||
//ÊÊÊÊ'float'ÊÊÊÊÊÊÊ=>Êarray('name'Ê=>Ê'float'),
|
||||
//ÊÊÊÊ'datetime'ÊÊÊÊ=>Êarray('name'Ê=>Ê'datetime',Ê'format'Ê=>Ê'Y-m-dÊh:i:s',Ê'formatter'Ê=>Ê'date'),
|
||||
//ÊÊÊÊ'timestamp'ÊÊÊ=>Êarray('name'Ê=>Ê'datetime',Ê'format'Ê=>Ê'Y-m-dÊh:i:s',Ê'formatter'Ê=>Ê'date'),
|
||||
//ÊÊÊÊ'time'ÊÊÊÊÊÊÊÊ=>Êarray('name'Ê=>Ê'time',Ê'format'Ê=>Ê'h:i:s',Ê'formatter'Ê=>Ê'date'),
|
||||
//ÊÊÊÊ'date'ÊÊÊÊÊÊÊÊ=>Êarray('name'Ê=>Ê'date',Ê'format'Ê=>Ê'Y-m-d',Ê'formatter'Ê=>Ê'date'),
|
||||
//ÊÊÊÊ'binary'ÊÊÊÊÊÊ=>Êarray('name'Ê=>Ê'blob'),
|
||||
//ÊÊÊÊ'boolean'ÊÊÊÊÊ=>Êarray('name'Ê=>Ê'tinyint',Ê'limit'Ê=>Ê'1'));
|
||||
|
||||
/**
|
||||
Ê*ÊEnterÊdescriptionÊhere...
|
||||
Ê*
|
||||
Ê*Ê@paramÊunknown_typeÊ$config
|
||||
Ê*Ê@returnÊunknown
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊ__constructÊ($config)
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊreturn parent::__construct($config);
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊConnectsÊtoÊtheÊdatabaseÊusingÊoptionsÊinÊtheÊgivenÊconfigurationÊarray.
|
||||
Ê*
|
||||
Ê*Ê@returnÊbooleanÊTrueÊifÊtheÊdatabaseÊcouldÊbeÊconnected,ÊelseÊfalse
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊconnectÊ()
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊ$configÊ=Ê$this->config;
|
||||
ÊÊÊÊÊÊÊÊ$connectÊ=Ê$config['connect'];
|
||||
|
||||
ÊÊÊÊÊÊÊÊ$this->connectedÊ=Êfalse;
|
||||
ÊÊÊÊÊÊÊÊ$this->connectionÊ=Ê$connect($config['database'],Ê$config['login'],Ê$config['password']);
|
||||
ÊÊÊÊÊÊÊÊifÊ($this->connection)
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ$this->connectedÊ=Êtrue;
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊelse
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ//die('CouldÊnotÊconnectÊtoÊDB.');
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊDisconnectsÊfromÊdatabase.
|
||||
Ê*
|
||||
Ê*Ê@returnÊbooleanÊTrueÊifÊtheÊdatabaseÊcouldÊbeÊdisconnected,ÊelseÊfalse
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊdisconnectÊ()
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊreturnÊ@odbc_close($this->connection);
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊExecutesÊgivenÊSQLÊstatement.
|
||||
Ê*
|
||||
Ê*Ê@paramÊstringÊ$sqlÊSQLÊstatement
|
||||
Ê*Ê@returnÊresourceÊResultÊresourceÊidentifier
|
||||
Ê*Ê@accessÊprotected
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊ_executeÊ($sql)
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊreturnÊodbc_exec($this->connection,Ê$sql);
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊReturnsÊaÊrowÊfromÊgivenÊresultsetÊasÊanÊarrayÊ.
|
||||
Ê*
|
||||
Ê*Ê@paramÊboolÊ$assocÊAssociativeÊarrayÊonly,ÊorÊboth?
|
||||
Ê*Ê@returnÊarrayÊTheÊfetchedÊrowÊasÊanÊarray
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊfetchRowÊ($assocÊ=Êfalse)
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊif(is_resource($this->_result))
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ$this->resultSet($this->_result);
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ$resultRowÊ=Ê$this->fetchResult();
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊ$resultRow;
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊelse
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊnull;
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊReturnsÊanÊarrayÊofÊsourcesÊ(tables)ÊinÊtheÊdatabase.
|
||||
Ê*
|
||||
Ê*Ê@returnÊarrayÊArrayÊofÊtablenamesÊinÊtheÊdatabase
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊlistSourcesÊ()
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊ$resultÊ=Êodbc_tables($this->connection);
|
||||
ÊÊÊÊÊÊÊÊifÊ(!$result)
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊarray();
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊelse
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ$tablesÊ=Êarray();
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊwhileÊ($lineÊ=Êodbc_fetch_array($result))
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ$tables[]Ê=Êstrtolower($line['TABLE_NAME']);
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊ$tables;
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
* Returns an array of the fields in given table name.
|
||||
*
|
||||
* @param Model $model Model object to describe
|
||||
* @return array Fields in table. Keys are name and type
|
||||
*/
|
||||
ÊÊÊÊfunctionÊ&describeÊ(&$model)
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊ$cacheÊ=Êparent::describe($model);
|
||||
ÊÊÊÊÊÊÊÊifÊ($cacheÊ!=Ênull)
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊ$cache;
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
|
||||
ÊÊÊÊÊÊÊÊ$fieldsÊ=Êarray();
|
||||
ÊÊÊÊÊÊÊÊ$sqlÊ=Ê'SELECTÊ*ÊFROMÊ'Ê.Ê$this->name($model->table) . ' LIMIT 1';
|
||||
ÊÊÊÊÊÊÊÊ$resultÊ=Êodbc_exec($this->connection,Ê$sql);
|
||||
|
||||
$count = odbc_num_fields($result);
|
||||
|
||||
ÊÊÊÊÊÊÊÊforÊ($i = 1;Ê$iÊ<=Ê$count;Ê$i++)
|
||||
{
|
||||
$cols[$i - 1]Ê=Êodbc_field_name($result,Ê$i);
|
||||
}
|
||||
|
||||
ÊÊÊÊÊÊÊÊforeachÊ($colsÊasÊ$column)
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ$typeÊ=Êodbc_field_type(odbc_exec($this->connection,"SELECTÊ"Ê.Ê$columnÊ.Ê"ÊFROMÊ"Ê.Ê$model->table),Ê1);
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊarray_push($fields,Êarray('name'Ê=>Ê$column,Ê'type'Ê=>Ê$type));
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
|
||||
ÊÊÊÊÊÊÊÊ$this->__cacheDescription($model->table,Ê$fields);
|
||||
ÊÊÊÊÊÊÊÊreturnÊ$fields;
|
||||
ÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊ
|
||||
|
||||
ÊÊÊÊfunctionÊnameÊ($data)
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊifÊ($dataÊ==Ê'*')
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊ'*';
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊÊ$posÊ=Êstrpos($data,Ê'`');
|
||||
ÊÊÊÊÊÊÊÊifÊ($posÊ===Êfalse)
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ$dataÊ=Ê''Ê.Êstr_replace('.',Ê'.',Ê$data)Ê.'';
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ//$dataÊ=Ê'`'.Êstr_replace('.',Ê'`.`',Ê$data)Ê.'`';
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊreturnÊ$data;
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊReturnsÊaÊquotedÊandÊescapedÊstringÊofÊ$dataÊforÊuseÊinÊanÊSQLÊstatement.
|
||||
Ê*
|
||||
Ê*Ê@paramÊstringÊ$dataÊStringÊtoÊbeÊpreparedÊforÊuseÊinÊanÊSQLÊstatement
|
||||
Ê*Ê@paramÊstringÊ$columnÊTheÊcolumnÊintoÊwhichÊthisÊdataÊwillÊbeÊinserted
|
||||
Ê*Ê@returnÊstringÊQuotedÊandÊescaped
|
||||
Ê*Ê@todoÊAddÊlogicÊthatÊformats/escapesÊdataÊbasedÊonÊcolumnÊtype
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊvalueÊ($data,Ê$columnÊ=Ênull)
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊ$parentÊ=Êparent::value($data,Ê$column);
|
||||
ÊÊÊÊÊÊÊÊifÊ($parentÊ!=Ênull)
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊ$parent;
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊifÊ($dataÊ===Ênull)
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊ'NULL';
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊifÊ(ini_get('magic_quotes_gpc')Ê==Ê1)
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ$dataÊ=Êstripslashes($data);
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊ//Ê$dataÊ=Êmysql_real_escape_string($data,Ê$this->connection);
|
||||
|
||||
ÊÊÊÊÊÊÊÊif(!is_numeric($data))
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ$returnÊ=Ê"'"Ê.Ê$dataÊ.Ê"'";
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊelse
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ$returnÊ=Ê$data;
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊreturnÊ$return;
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊNotÊsureÊaboutÊthisÊone,ÊMySQLÊneedsÊitÊbutÊdoesÊODBC?ÊÊSaferÊjustÊtoÊleaveÊit
|
||||
Ê*ÊTranslatesÊbetweenÊPHPÊbooleanÊvaluesÊandÊMySQLÊ(faked)ÊbooleanÊvalues
|
||||
Ê*ÊÊ
|
||||
Ê*Ê@paramÊmixedÊ$dataÊValueÊtoÊbeÊtranslated
|
||||
Ê*Ê@returnÊmixedÊConvertedÊbooleanÊvalue
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊbooleanÊ($data)
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊifÊ($dataÊ===ÊtrueÊ||Ê$dataÊ===Êfalse)
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊifÊ($dataÊ===Êtrue)
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊreturnÊ1;
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊ0;
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊelse
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊifÊ(intval($dataÊ!==Ê0))
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊreturnÊtrue;
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊfalse;
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊBeginÊaÊtransaction
|
||||
Ê*
|
||||
Ê*Ê@paramÊunknown_typeÊ$model
|
||||
Ê*Ê@returnÊbooleanÊTrueÊonÊsuccess,ÊfalseÊonÊfail
|
||||
Ê*Ê(i.e.ÊifÊtheÊdatabase/modelÊdoesÊnotÊsupportÊtransactions).
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊbeginÊ(&$model)
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊifÊ(parent::begin($model))
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊifÊ(odbc_autocommit($this->connection, false))
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ$this->__transactionStartedÊ=Êtrue;
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊreturnÊtrue;
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊreturnÊfalse;
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊCommitÊaÊtransaction
|
||||
Ê*
|
||||
Ê*Ê@paramÊunknown_typeÊ$model
|
||||
Ê*Ê@returnÊbooleanÊTrueÊonÊsuccess,ÊfalseÊonÊfail
|
||||
Ê*Ê(i.e.ÊifÊtheÊdatabase/modelÊdoesÊnotÊsupportÊtransactions,
|
||||
Ê*ÊorÊaÊtransactionÊhasÊnotÊstarted).
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊcommitÊ(&$model)
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊifÊ(parent::commit($model))
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
if (odbc_commit($this->connection))
|
||||
{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ $this->__transactionStarted = false;
|
||||
return true;
|
||||
}
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊreturnÊfalse;
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊRollbackÊaÊtransaction
|
||||
Ê*
|
||||
Ê*Ê@paramÊunknown_typeÊ$model
|
||||
Ê*Ê@returnÊbooleanÊTrueÊonÊsuccess,ÊfalseÊonÊfail
|
||||
Ê*Ê(i.e.ÊifÊtheÊdatabase/modelÊdoesÊnotÊsupportÊtransactions,
|
||||
Ê*ÊorÊaÊtransactionÊhasÊnotÊstarted).
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊrollbackÊ(&$model)
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊifÊ(parent::rollback($model))
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ$this->__transactionStarted = false;
|
||||
returnÊodbc_rollback($this->connection);
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊreturnÊfalse;
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊReturnsÊaÊformattedÊerrorÊmessageÊfromÊpreviousÊdatabaseÊoperation.
|
||||
Ê*
|
||||
Ê*Ê@returnÊstringÊErrorÊmessageÊwithÊerrorÊnumber
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊlastErrorÊ()
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊifÊ(odbc_error($this->connection))
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊodbc_error($this->connection).':Ê'.odbc_errormsg($this->connection);
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊreturnÊnull;
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊReturnsÊnumberÊofÊaffectedÊrowsÊinÊpreviousÊdatabaseÊoperation.ÊIfÊnoÊpreviousÊoperationÊexists,
|
||||
Ê*ÊthisÊreturnsÊfalse.
|
||||
Ê*
|
||||
Ê*Ê@returnÊintÊNumberÊofÊaffectedÊrows
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊlastAffectedÊ()
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊifÊ($this->_result)
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊnull;
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊreturnÊnull;
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊReturnsÊnumberÊofÊrowsÊinÊpreviousÊresultset.ÊIfÊnoÊpreviousÊresultsetÊexists,
|
||||
Ê*ÊthisÊreturnsÊfalse.
|
||||
Ê*
|
||||
Ê*Ê@returnÊintÊNumberÊofÊrowsÊinÊresultset
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊlastNumRowsÊ()
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊifÊ($this->_result)
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊ@odbc_num_rows($this->_result);
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊreturnÊnull;
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊReturnsÊtheÊIDÊgeneratedÊfromÊtheÊpreviousÊINSERTÊoperation.
|
||||
Ê*
|
||||
Ê*Ê@paramÊunknown_typeÊ$source
|
||||
Ê*Ê@returnÊint
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊlastInsertIdÊ($sourceÊ=Ênull)
|
||||
ÊÊÊÊ{
|
||||
$result = $this->fetchAll('SELECT @@IDENTITY');
|
||||
return $result[0];
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊEnterÊdescriptionÊhere...
|
||||
Ê*
|
||||
Ê*Ê@paramÊstringÊ$realÊRealÊdatabase-layerÊcolumnÊtypeÊ(i.e.Ê"varchar(255)")
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊcolumn($real)
|
||||
ÊÊÊÊ{
|
||||
if (is_array($real))
|
||||
{
|
||||
$col = $real['name'];
|
||||
if (isset($real['limit']))
|
||||
{
|
||||
$col .= '('.$real['limit'].')';
|
||||
}
|
||||
return $col;
|
||||
}
|
||||
|
||||
ÊÊÊÊÊÊÊÊreturnÊ$real;
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊEnterÊdescriptionÊhere...
|
||||
Ê*
|
||||
Ê*Ê@paramÊunknown_typeÊ$results
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊresultSet(&$results)
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊ$this->resultsÊ=&Ê$results;
|
||||
ÊÊÊÊÊÊÊÊ$this->mapÊ=Êarray();
|
||||
ÊÊÊÊÊÊÊÊ$num_fieldsÊ=Êodbc_num_fields($results);
|
||||
ÊÊÊÊÊÊÊÊ$indexÊ=Ê0;
|
||||
ÊÊÊÊÊÊÊÊ$jÊ=Ê0;
|
||||
|
||||
ÊÊÊÊÊÊÊÊwhileÊ($jÊ<Ê$num_fields)
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ$columnÊ=Êodbc_fetch_array($results,$j);
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊifÊ(!empty($column->table))
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ$this->map[$index++]Ê=Êarray($column->table,Ê$column->name);
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊelse
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊechoÊarray(0,Ê$column->name);
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ$this->map[$index++]Ê=Êarray(0,Ê$column->name);
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ$j++;
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊ}
|
||||
|
||||
/**
|
||||
Ê*ÊFetchesÊtheÊnextÊrowÊfromÊtheÊcurrentÊresultÊset
|
||||
Ê*
|
||||
Ê*Ê@returnÊunknown
|
||||
Ê*/
|
||||
ÊÊÊÊfunctionÊfetchResult()
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊifÊ($rowÊ=Êodbc_fetch_row($this->results))
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ$resultRowÊ=Êarray();
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ$iÊ=0;
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊforeachÊ($rowÊasÊ$indexÊ=>Ê$field)
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊlist($table,Ê$column)Ê=Ê$this->map[$index];
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ$resultRow[$table][$column]Ê=Ê$row[$index];
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊÊ$i++;
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊ$resultRow;
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊÊÊÊÊelse
|
||||
ÊÊÊÊÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊÊÊÊÊreturnÊfalse;
|
||||
ÊÊÊÊÊÊÊÊ}
|
||||
ÊÊÊÊ}
|
||||
|
||||
ÊÊÊÊfunctionÊbuildSchemaQuery($schema)
|
||||
ÊÊÊÊ{
|
||||
ÊÊÊÊÊÊÊÊ$searchÊÊ=Êarray('{AUTOINCREMENT}',Ê'{PRIMARY}',Ê'{UNSIGNED}',Ê'{FULLTEXT}',
|
||||
ÊÊÊÊÊÊÊÊ'{FULLTEXT_MYSQL}',Ê'{BOOLEAN}',Ê'{UTF_8}');
|
||||
ÊÊÊÊÊÊÊÊ$replaceÊ=Êarray('int(11)ÊnotÊnullÊauto_increment',Ê'primaryÊkey',Ê'unsigned',
|
||||
ÊÊÊÊÊÊÊÊ'FULLTEXT',Ê'FULLTEXT',Ê'enumÊ(\'true\',Ê\'false\')ÊNOTÊNULLÊdefaultÊ\'true\'',
|
||||
ÊÊÊÊÊÊÊÊ'/*!40100ÊCHARACTERÊSETÊutf8ÊCOLLATEÊutf8_unicode_ciÊ*/');
|
||||
ÊÊÊÊÊÊÊÊ$queryÊ=Êtrim(str_replace($search,Ê$replace,Ê$schema));
|
||||
ÊÊÊÊÊÊÊÊreturnÊ$query;
|
||||
ÊÊÊÊ}
|
||||
}
|
||||
?>
|
|
@ -55,8 +55,8 @@ class DboPostgres extends DboSource
|
|||
'port' => 5432);
|
||||
|
||||
var $columns = array(
|
||||
'primary_key' => array('name' => 'serial primary key'),
|
||||
'string' => array('name' => 'character varying', 'limit' => '255'),
|
||||
'primary_key' => array('name' => 'serial NOT NULL'),
|
||||
'string' => array('name' => 'varchar', 'limit' => '255'),
|
||||
'text' => array('name' => 'text'),
|
||||
'integer' => array('name' => 'integer'),
|
||||
'float' => array('name' => 'float'),
|
||||
|
@ -82,7 +82,7 @@ class DboPostgres extends DboSource
|
|||
$config = $this->config;
|
||||
$connect = $config['connect'];
|
||||
|
||||
$this->connection = $connect("dbname={$config['database']} user={$config['login']} password={$config['password']}");
|
||||
$this->connection = $connect("host={$config['host']} port={$config['port']} dbname={$config['database']} user={$config['login']} password={$config['password']}");
|
||||
if ($this->connection)
|
||||
{
|
||||
$this->connected = true;
|
||||
|
@ -116,27 +116,6 @@ class DboPostgres extends DboSource
|
|||
return pg_query($this->connection, $sql);
|
||||
}
|
||||
|
||||
function query ()
|
||||
{
|
||||
$args = func_get_args();
|
||||
if (count($args) == 1)
|
||||
{
|
||||
return $this->fetchAll($args[0]);
|
||||
}
|
||||
elseif (count($args) > 1 && strpos(strtolower($args[0]), 'findby') === 0)
|
||||
{
|
||||
$field = Inflector::underscore(preg_replace('/findBy/i', '', $args[0]));
|
||||
$query = '"' . $args[2]->name . '"."' . $field . '" = ' . $this->value($args[1][0]);
|
||||
return $args[2]->find($query);
|
||||
}
|
||||
elseif (count($args) > 1 && strpos(strtolower($args[0]), 'findallby') === 0)
|
||||
{
|
||||
$field = Inflector::underscore(preg_replace('/findAllBy/i', '', $args[0]));
|
||||
$query = '"' . $args[2]->name . '"."' . $field . '" = ' . $this->value($args[1][0]);
|
||||
return $args[2]->findAll($query);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a row from given resultset as an array .
|
||||
*
|
||||
|
@ -163,13 +142,18 @@ class DboPostgres extends DboSource
|
|||
*/
|
||||
function listSources ()
|
||||
{
|
||||
$sql = "SELECT table_name as name FROM information_schema.tables WHERE table_schema = 'public';";
|
||||
$cache = parent::listSources();
|
||||
if ($cache != null)
|
||||
{
|
||||
return $cache;
|
||||
}
|
||||
|
||||
$result = $this->query($sql);
|
||||
$sql = "SELECT table_name as name FROM INFORMATION_SCHEMA.tables WHERE table_schema = 'public';";
|
||||
$result = $this->fetchAll($sql);
|
||||
|
||||
if (!$result)
|
||||
{
|
||||
return null;
|
||||
return array();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -178,6 +162,7 @@ class DboPostgres extends DboSource
|
|||
{
|
||||
$tables[] = $item[0]['name'];
|
||||
}
|
||||
parent::listSources($tables);
|
||||
return $tables;
|
||||
}
|
||||
}
|
||||
|
@ -257,7 +242,7 @@ class DboPostgres extends DboSource
|
|||
|
||||
$fields = false;
|
||||
|
||||
$cols = $this->query("SELECT column_name AS name, data_type AS type, is_nullable AS null, column_default AS default FROM information_schema.columns WHERE table_name =".$this->value($model->table)." ORDER BY ordinal_position");
|
||||
$cols = $this->fetchAll("SELECT DISTINCT column_name AS name, data_type AS type, is_nullable AS null, column_default AS default, ordinal_position FROM information_schema.columns WHERE table_name =".$this->value($model->table)." ORDER BY ordinal_position");
|
||||
|
||||
foreach ($cols as $column)
|
||||
{
|
||||
|
@ -316,6 +301,16 @@ class DboPostgres extends DboSource
|
|||
}
|
||||
switch ($column)
|
||||
{
|
||||
case 'integer':
|
||||
if ($data == '')
|
||||
{
|
||||
return 'DEFAULT';
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = pg_escape_string($data);
|
||||
}
|
||||
break;
|
||||
case 'binary':
|
||||
$data = pg_escape_bytea($data);
|
||||
break;
|
||||
|
@ -327,8 +322,8 @@ class DboPostgres extends DboSource
|
|||
{
|
||||
$data = stripslashes($data);
|
||||
}
|
||||
|
||||
$data = pg_escape_string($data);
|
||||
break;
|
||||
}
|
||||
|
||||
$return = "'" . $data . "'";
|
||||
|
@ -483,6 +478,16 @@ class DboPostgres extends DboSource
|
|||
*/
|
||||
function column($real)
|
||||
{
|
||||
if (is_array($real))
|
||||
{
|
||||
$col = $real['name'];
|
||||
if (isset($real['limit']))
|
||||
{
|
||||
$col .= '('.$real['limit'].')';
|
||||
}
|
||||
return $col;
|
||||
}
|
||||
|
||||
$col = r(')', '', $real);
|
||||
$limit = null;
|
||||
@list($col, $limit) = explode('(', $col);
|
||||
|
@ -499,7 +504,7 @@ class DboPostgres extends DboSource
|
|||
{
|
||||
return 'boolean';
|
||||
}
|
||||
if (strpos($col, 'integer') !== false)
|
||||
if (strpos($col, 'int') !== false && $col != 'interval')
|
||||
{
|
||||
return 'integer';
|
||||
}
|
||||
|
@ -515,7 +520,7 @@ class DboPostgres extends DboSource
|
|||
{
|
||||
return 'binary';
|
||||
}
|
||||
if (in_array($col, array('float', 'double', 'decimal', 'real')))
|
||||
if (in_array($col, array('float', 'float4', 'float8', 'double', 'decimal', 'real')))
|
||||
{
|
||||
return 'float';
|
||||
}
|
||||
|
@ -645,7 +650,15 @@ class DboPostgres extends DboSource
|
|||
{
|
||||
$insert = $this->value($value, $model->getColumnType($fields[$count]));
|
||||
}
|
||||
|
||||
if ($insert === '\'\'')
|
||||
{
|
||||
unset($fieldInsert[$count]);
|
||||
}
|
||||
else
|
||||
{
|
||||
$valueInsert[] = $insert;
|
||||
}
|
||||
unset($insert);
|
||||
$count++;
|
||||
}
|
||||
|
|
|
@ -453,8 +453,15 @@ class Model extends Object
|
|||
|
||||
foreach ($this->{$type} as $assoc => $value)
|
||||
{
|
||||
if (is_numeric($assoc))
|
||||
{
|
||||
unset($this->{$type}[$assoc]);
|
||||
$assoc = $value;
|
||||
$value = array();
|
||||
$this->{$type}[$assoc] = $value;
|
||||
}
|
||||
$className = $assoc;
|
||||
if (isset($value['className']) && $value['className'] !== null)
|
||||
if (isset($value['className']) && !empty($value['className']))
|
||||
{
|
||||
$className = $value['className'];
|
||||
}
|
||||
|
@ -480,11 +487,11 @@ class Model extends Object
|
|||
$colKey = Inflector::underscore($className);
|
||||
if(ClassRegistry::isKeySet($colKey))
|
||||
{
|
||||
$this->{$className} =& ClassRegistry::getObject($colKey);
|
||||
$this->{$className} = ClassRegistry::getObject($colKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->{$className} =& new $className();
|
||||
$this->{$className} = new $className();
|
||||
}
|
||||
|
||||
$this->alias[$assoc] = $this->{$className}->table;
|
||||
|
@ -594,11 +601,18 @@ class Model extends Object
|
|||
{
|
||||
if (is_array($one))
|
||||
{
|
||||
$data = $one;
|
||||
if (countdim($one) == 1)
|
||||
{
|
||||
$data = array($this->name => $one);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = array($one=>$two);
|
||||
$data = $one;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = array($this->name => array($one => $two));
|
||||
}
|
||||
|
||||
foreach ($data as $n => $v)
|
||||
|
@ -823,6 +837,7 @@ class Model extends Object
|
|||
}
|
||||
|
||||
$whitelist = !(empty($fieldList) || count($fieldList) == 0);
|
||||
$this->validationErrors = array();
|
||||
|
||||
if(!$this->beforeValidate())
|
||||
{
|
||||
|
@ -976,8 +991,8 @@ class Model extends Object
|
|||
foreach ($y as $assoc => $value)
|
||||
{
|
||||
$joinTable[] = $this->hasAndBelongsToMany[$assoc]['joinTable'];
|
||||
$mainKey = $this->hasAndBelongsToMany[$assoc]['foreignKey'];
|
||||
$keys[] = $mainKey;
|
||||
$mainKey[] = $this->hasAndBelongsToMany[$assoc]['foreignKey'];
|
||||
$keys[] = $this->hasAndBelongsToMany[$assoc]['foreignKey'];
|
||||
$keys[] = $this->hasAndBelongsToMany[$assoc]['associationForeignKey'];
|
||||
$fields[] = join(',', $keys);
|
||||
unset($keys);
|
||||
|
@ -1005,7 +1020,7 @@ class Model extends Object
|
|||
for ($count = 0; $count < $total; $count++)
|
||||
{
|
||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
$db->execute("DELETE FROM {$joinTable[$count]} WHERE $mainKey = '{$id}'");
|
||||
$db->execute("DELETE FROM {$joinTable[$count]} WHERE {$mainKey[$count]} = '{$id}'");
|
||||
if(!empty($newValue[$count]))
|
||||
{
|
||||
$db->execute("INSERT INTO {$joinTable[$count]} ({$fields[$count]}) VALUES {$newValue[$count]}");
|
||||
|
|
|
@ -449,8 +449,15 @@ class Model extends Object
|
|||
|
||||
foreach ($this->{$type} as $assoc => $value)
|
||||
{
|
||||
if (is_numeric($assoc))
|
||||
{
|
||||
unset($this->{$type}[$assoc]);
|
||||
$assoc = $value;
|
||||
$value = array();
|
||||
$this->{$type}[$assoc] = $value;
|
||||
}
|
||||
$className = $assoc;
|
||||
if (isset($value['className']) && $value['className'] !== null)
|
||||
if (isset($value['className']) && !empty($value['className']))
|
||||
{
|
||||
$className = $value['className'];
|
||||
}
|
||||
|
@ -590,11 +597,18 @@ class Model extends Object
|
|||
{
|
||||
if (is_array($one))
|
||||
{
|
||||
$data = $one;
|
||||
if (countdim($one) == 1)
|
||||
{
|
||||
$data = array($this->name => $one);
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = array($one=>$two);
|
||||
$data = $one;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$data = array($this->name => array($one => $two));
|
||||
}
|
||||
|
||||
foreach ($data as $n => $v)
|
||||
|
@ -819,6 +833,7 @@ class Model extends Object
|
|||
}
|
||||
|
||||
$whitelist = !(empty($fieldList) || count($fieldList) == 0);
|
||||
$this->validationErrors = array();
|
||||
|
||||
if(!$this->beforeValidate())
|
||||
{
|
||||
|
@ -972,8 +987,8 @@ class Model extends Object
|
|||
foreach ($y as $assoc => $value)
|
||||
{
|
||||
$joinTable[] = $this->hasAndBelongsToMany[$assoc]['joinTable'];
|
||||
$mainKey = $this->hasAndBelongsToMany[$assoc]['foreignKey'];
|
||||
$keys[] = $mainKey;
|
||||
$mainKey[] = $this->hasAndBelongsToMany[$assoc]['foreignKey'];
|
||||
$keys[] = $this->hasAndBelongsToMany[$assoc]['foreignKey'];
|
||||
$keys[] = $this->hasAndBelongsToMany[$assoc]['associationForeignKey'];
|
||||
$fields[] = join(',', $keys);
|
||||
unset($keys);
|
||||
|
@ -1001,7 +1016,7 @@ class Model extends Object
|
|||
for ($count = 0; $count < $total; $count++)
|
||||
{
|
||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||
$db->execute("DELETE FROM {$joinTable[$count]} WHERE $mainKey = '{$id}'");
|
||||
$db->execute("DELETE FROM {$joinTable[$count]} WHERE {$mainKey[$count]} = '{$id}'");
|
||||
if(!empty($newValue[$count]))
|
||||
{
|
||||
$db->execute("INSERT INTO {$joinTable[$count]} ({$fields[$count]}) VALUES {$newValue[$count]}");
|
||||
|
|
|
@ -91,7 +91,7 @@ class Object
|
|||
* Calls a controller's method from any location.
|
||||
*
|
||||
* @param string $url URL in the form of Cake URL ("/controller/method/parameter")
|
||||
* @param array $extra If array includes the key "render" it sets the AutoRender to true.
|
||||
* @param array $extra If array includes the key "return" it sets the AutoRender to true.
|
||||
* @return boolean Success
|
||||
*/
|
||||
function requestAction ($url, $extra = array())
|
||||
|
|
|
@ -52,6 +52,23 @@ class Router extends Object {
|
|||
*/
|
||||
var $routes = array();
|
||||
|
||||
function __construct ()
|
||||
{
|
||||
if(defined('CAKE_ADMIN'))
|
||||
{
|
||||
$admin = CAKE_ADMIN;
|
||||
if(!empty($admin))
|
||||
{
|
||||
$this->routes[] = array (
|
||||
'/:'.$admin.'/:controller/:action/* (default)',
|
||||
'/^(?:\/(?:('.$admin.')(?:\\/([a-zA-Z0-9_\\-\\.]+)(?:\\/([a-zA-Z0-9_\\-\\.]+)(?:[\\/\\?](.*))?)?)?))[\/]*$/',
|
||||
array($admin, 'controller', 'action'),
|
||||
array()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Better description. Returns this object's routes array. Returns false if there are no routes available.
|
||||
*
|
||||
|
@ -134,21 +151,6 @@ class Router extends Object {
|
|||
array('controller', 'action'),
|
||||
array());
|
||||
|
||||
if(defined('CAKE_ADMIN'))
|
||||
{
|
||||
$admin = CAKE_ADMIN;
|
||||
if(!empty($admin))
|
||||
{
|
||||
$this->routes[] = array
|
||||
(
|
||||
'/:'.$admin.'/:controller/:action/* (default)',
|
||||
'/^(?:\/(?:('.$admin.')(?:\\/([a-zA-Z0-9_\\-\\.]+)(?:\\/([a-zA-Z0-9_\\-\\.]+)(?:[\\/\\?](.*))?)?)?))[\/]*$/',
|
||||
array($admin, 'controller', 'action'),
|
||||
array());
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->connect('/bare/:controller/:action/*', array('bare'=>'1'));
|
||||
$this->connect('/ajax/:controller/:action/*', array('bare'=>'1'));
|
||||
|
||||
|
|
|
@ -334,14 +334,15 @@ class FormHelper extends Helper
|
|||
*/
|
||||
function generateSelectDiv($tagName, $prompt, $options, $selected=null, $selectAttr=null, $optionAttr=null, $required=false, $errorMsg=null)
|
||||
{
|
||||
$selectAttr['id'] = strtolower(str_replace('/', '_',$tagName));;
|
||||
$selectAttr['id'] = strtolower(str_replace('/', '_',$tagName));
|
||||
$str = $this->Html->selectTag( $tagName, $options, $selected, $selectAttr, $optionAttr );
|
||||
$strLabel = $this->labelTag( $tagName, $prompt );
|
||||
|
||||
$divClass = "optional";
|
||||
|
||||
if($required)
|
||||
{
|
||||
$divClass = "required";
|
||||
}
|
||||
|
||||
$strError = "";// initialize the error to empty.
|
||||
|
||||
|
|
|
@ -1083,7 +1083,7 @@ function url($url = null, $return = false)
|
|||
}
|
||||
}
|
||||
// do not display the select tag if no option elements are avaible
|
||||
if (!is_array($optionElements) || count($optionElements) == 0)
|
||||
if (!is_array($optionElements))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -214,14 +214,39 @@ class JavascriptHelper extends Helper
|
|||
* @param string $q The type of quote to use
|
||||
* @return string A JSON code block
|
||||
*/
|
||||
function object ($data = array(), $block = false, $prefix = '', $postfix = '', $stringKeys = array(), $quoteKeys = true, $q = "'")
|
||||
function object ($data = array(), $block = false, $prefix = '', $postfix = '', $stringKeys = array(), $quoteKeys = true, $q = "\"")
|
||||
{
|
||||
if (is_object($data))
|
||||
{
|
||||
$data = get_object_vars($data);
|
||||
}
|
||||
|
||||
$out = array();
|
||||
$key = array();
|
||||
if (is_array($data))
|
||||
{
|
||||
$keys = array_keys($data);
|
||||
}
|
||||
$numeric = true;
|
||||
|
||||
if (!empty($keys))
|
||||
{
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
if (!is_numeric($key))
|
||||
{
|
||||
$numeric = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($data as $key => $val)
|
||||
{
|
||||
if (is_array($val))
|
||||
if (is_array($val) || is_object($val))
|
||||
{
|
||||
$out[] = $key.':'.$this->object($val, false, '', '', $stringKeys, $quoteKeys, $q);
|
||||
$val = $this->object($val, false, '', '', $stringKeys, $quoteKeys, $q);
|
||||
$out[] = $val;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -233,14 +258,28 @@ class JavascriptHelper extends Helper
|
|||
{
|
||||
$val = 'null';
|
||||
}
|
||||
}
|
||||
|
||||
$out[] = $key.':'.$val;
|
||||
if (!$numeric)
|
||||
{
|
||||
$val = $key.':'.$val;
|
||||
}
|
||||
$out[] = $val;
|
||||
}
|
||||
$rt = $prefix.'{'.join(', ', $out).'}'.$postfix;
|
||||
|
||||
if (!$numeric)
|
||||
{
|
||||
$rt = '{'.join(', ', $out).'}';
|
||||
}
|
||||
else
|
||||
{
|
||||
$rt = 'new Array('.join(', ', $out).')';
|
||||
}
|
||||
$rt = $prefix.$rt.$postfix;
|
||||
|
||||
if ($block)
|
||||
{
|
||||
return $this->codeBlock($rt);
|
||||
$rt = $this->codeBlock($rt);
|
||||
}
|
||||
return $rt;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,8 @@ if(!empty($this->controller->{$model}->alias))
|
|||
}
|
||||
}
|
||||
?>
|
||||
<table class="inav" cellspacing="0">
|
||||
<table class="inav" cellpadding="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<?php
|
||||
foreach ($fieldNames as $fieldName)
|
||||
|
@ -60,6 +61,8 @@ foreach ($fieldNames as $fieldName)
|
|||
}
|
||||
?>
|
||||
<th>Actions</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
</tr>
|
||||
<?php
|
||||
$iRowIndex = 0;
|
||||
|
@ -116,6 +119,7 @@ if(is_array($data))
|
|||
}
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
<ul class="actions">
|
||||
<li><?php echo $html->link('New '.$humanSingularName, $path.$this->viewPath.'/add'); ?></li>
|
||||
|
|
|
@ -33,15 +33,39 @@ ini_set('error_reporting', '7');
|
|||
|
||||
define ('DS', DIRECTORY_SEPARATOR);
|
||||
|
||||
/**
|
||||
* Change these setting only if your install
|
||||
* is different from a distribution install.
|
||||
*
|
||||
*/
|
||||
define ('ROOT', dirname(dirname(dirname(__FILE__))).DS);
|
||||
define ('APP_DIR', 'app');
|
||||
$app = 'app';
|
||||
$core = null;
|
||||
$root = dirname(dirname(dirname(__FILE__)));
|
||||
$here = $argv[0];
|
||||
$dataSource = 'default';
|
||||
|
||||
for ($i = 1; $i < count($argv); $i += 2)
|
||||
{
|
||||
// Process command-line modifiers here
|
||||
switch (strtolower($argv[$i]))
|
||||
{
|
||||
case '-app':
|
||||
$app = $argv[$i + 1];
|
||||
break;
|
||||
case '-core':
|
||||
$core = $argv[$i + 1];
|
||||
break;
|
||||
case '-root':
|
||||
$root = $argv[$i + 1];
|
||||
break;
|
||||
case '-datasource':
|
||||
$dataSource = $argv[$i + 1];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
define ('ROOT', $root.DS);
|
||||
define ('APP_DIR', $app);
|
||||
define ('APP_PATH', $app.DS);
|
||||
define ('DEBUG', 1);
|
||||
define ('CORE_PATH', $core);
|
||||
define ('CAKE_CORE_INCLUDE_PATH', ROOT);
|
||||
define('CORE_PATH', CAKE_CORE_INCLUDE_PATH);
|
||||
define('DATASOURCE', $dataSource);
|
||||
|
||||
define ('DEBUG', 1);
|
||||
ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.CAKE_CORE_INCLUDE_PATH.PATH_SEPARATOR.ROOT.DS.APP_DIR.DS);
|
||||
|
@ -49,7 +73,14 @@ ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.CAKE_CORE_INCLUDE_
|
|||
require ('cake'.DS.'basics.php');
|
||||
require ('cake'.DS.'config'.DS.'paths.php');
|
||||
require (CONFIGS.'core.php');
|
||||
require (CONFIGS.'database.php');
|
||||
if (file_exists( CONFIGS.'database.php' ))
|
||||
{
|
||||
require_once (CONFIGS.'database.php');
|
||||
}
|
||||
else
|
||||
{
|
||||
die("Unable to find /app/config/database.php. Please create it before continuing.\n\n");
|
||||
}
|
||||
uses ('neat_array');
|
||||
uses ('object');
|
||||
uses ('session');
|
||||
|
@ -143,6 +174,7 @@ class AclCLI {
|
|||
*/
|
||||
function __construct ($command, $args)
|
||||
{
|
||||
$this->dataSource = DATASOURCE;
|
||||
$acl = new AclComponent();
|
||||
$this->acl = $acl->getACL();
|
||||
|
||||
|
@ -255,7 +287,7 @@ class AclCLI {
|
|||
extract($this->__dataVars());
|
||||
$node = &new $class;
|
||||
|
||||
if (!$node->setParent(intval($this->args[2]), intval($this->args[1])))
|
||||
if (!$node->setParent($this->args[2], $this->args[1]))
|
||||
{
|
||||
fwrite($this->stdout, "Error in setting new parent. Please make sure the parent node exists, and is not a descendant of the node specified.\n");
|
||||
}
|
||||
|
@ -377,37 +409,38 @@ class AclCLI {
|
|||
$db =& ConnectionManager::getDataSource($this->dataSource);
|
||||
fwrite($this->stdout, "Initializing Database...\n");
|
||||
fwrite($this->stdout, "Creating access control objects table (acos)...\n");
|
||||
$sql = " CREATE TABLE `acos` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`object_id` int(11) default NULL,
|
||||
`alias` varchar(255) NOT NULL default '',
|
||||
`lft` int(11) default NULL,
|
||||
`rght` int(11) default NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
|
||||
$sql = " CREATE TABLE ".$db->name('acos')." (
|
||||
".$db->name('id')." ".$db->column($db->columns['primary_key']).",
|
||||
".$db->name('object_id')." ".$db->column($db->columns['integer'])." default NULL,
|
||||
".$db->name('alias')." ".$db->column($db->columns['string'])." NOT NULL default '',
|
||||
".$db->name('lft')." ".$db->column($db->columns['integer'])." default NULL,
|
||||
".$db->name('rght')." ".$db->column($db->columns['integer'])." default NULL,
|
||||
PRIMARY KEY (".$db->name('id').")
|
||||
);";
|
||||
$db->query($sql);
|
||||
|
||||
fwrite($this->stdout, "Creating access request objects table (aros)...\n");
|
||||
$sql2 = "CREATE TABLE `aros` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`user_id` int(11) default NULL,
|
||||
`alias` varchar(255) NOT NULL default '',
|
||||
`lft` int(11) default NULL,
|
||||
`rght` int(11) default NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
$sql2 = "CREATE TABLE ".$db->name('aros')." (
|
||||
".$db->name('id')." ".$db->column($db->columns['primary_key']).",
|
||||
".$db->name('user_id')." ".$db->column($db->columns['integer'])." default NULL,
|
||||
".$db->name('alias')." ".$db->column($db->columns['string'])." NOT NULL default '',
|
||||
".$db->name('lft')." ".$db->column($db->columns['integer'])." default NULL,
|
||||
".$db->name('rght')." ".$db->column($db->columns['integer'])." default NULL,
|
||||
PRIMARY KEY (".$db->name('id').")
|
||||
);";
|
||||
$db->query($sql2);
|
||||
|
||||
fwrite($this->stdout, "Creating relationships table (aros_acos)...\n");
|
||||
$sql3 = "CREATE TABLE `aros_acos` (
|
||||
`id` int(11) NOT NULL auto_increment,
|
||||
`aro_id` int(11) default NULL,
|
||||
`aco_id` int(11) default NULL,
|
||||
`_create` int(1) NOT NULL default '0',
|
||||
`_read` int(1) NOT NULL default '0',
|
||||
`_update` int(1) NOT NULL default '0',
|
||||
`_delete` int(11) NOT NULL default '0',
|
||||
PRIMARY KEY (`id`)
|
||||
$sql3 = "CREATE TABLE ".$db->name('aros_acos')." (
|
||||
".$db->name('id')." ".$db->column($db->columns['primary_key']).",
|
||||
".$db->name('aro_id')." ".$db->column($db->columns['integer'])." default NULL,
|
||||
".$db->name('aco_id')." ".$db->column($db->columns['integer'])." default NULL,
|
||||
".$db->name('_create')." ".$db->column($db->columns['integer'])." NOT NULL default '0',
|
||||
".$db->name('_read')." ".$db->column($db->columns['integer'])." NOT NULL default '0',
|
||||
".$db->name('_update')." ".$db->column($db->columns['integer'])." NOT NULL default '0',
|
||||
".$db->name('_delete')." ".$db->column($db->columns['integer'])." NOT NULL default '0',
|
||||
PRIMARY KEY (".$db->name('id').")
|
||||
);";
|
||||
$db->query($sql3);
|
||||
|
||||
|
|
|
@ -59,6 +59,12 @@ define ('APP_DIR', $app);
|
|||
define ('APP_PATH', $app.DS);
|
||||
define ('DEBUG', 1);
|
||||
define ('CORE_PATH', $core);
|
||||
define('CAKE_CORE_INCLUDE_PATH', ROOT);
|
||||
|
||||
if(function_exists('ini_set'))
|
||||
{
|
||||
ini_set('include_path',ini_get('include_path').PATH_SEPARATOR.CAKE_CORE_INCLUDE_PATH.PATH_SEPARATOR.ROOT.DS.APP_DIR.DS);
|
||||
}
|
||||
|
||||
require_once (ROOT.'cake'.DS.'basics.php');
|
||||
require_once (ROOT.'cake'.DS.'config'.DS.'paths.php');
|
||||
|
@ -842,7 +848,7 @@ class Bake {
|
|||
$editView .= "<form action=\"/{$temp->viewPath}/edit/<?php echo \$data['{$objModel->tableToModel[$objModel->table]}']['$id'] ?>\" method=\"post\">\n";
|
||||
|
||||
$fields = $this->generateFields($temp->generateFieldNames(null, true));
|
||||
$fields .= "<?php echo \$html->hidden('{$objModel->table}/{$id}', array('value' => \$data['{$objModel->tableToModel[$objModel->table]}']['$id']))?>";
|
||||
$fields .= "<?php echo \$html->hidden('{$objModel->name}/{$id}', array('value' => \$data['{$objModel->tableToModel[$objModel->table]}']['$id']))?>";
|
||||
$fields .= $this->generateSubmitDiv('Save');
|
||||
|
||||
$editView .= $fields;
|
||||
|
@ -972,7 +978,7 @@ class Bake {
|
|||
$components = explode(',', $componentsListTrimmed);
|
||||
}
|
||||
|
||||
$wannaDoScaffolding = $this->getInput("Would to include some basic scaffolded actions (index, add, view, edit)?", array('y','n'), 'n');
|
||||
$wannaDoScaffolding = $this->getInput("Would to include some basic class methods (index(), add(), view(), edit())?", array('y','n'), 'n');
|
||||
|
||||
if (strtolower($wannaDoScaffolding) == 'y' || strtolower($wannaDoScaffolding) == 'yes')
|
||||
{
|
||||
|
@ -1019,6 +1025,8 @@ class Bake {
|
|||
$actions .= "\t\t\t}\n";
|
||||
$actions .= "\t\t\telse\n";
|
||||
$actions .= "\t\t\t{\n";
|
||||
$actions .= "\t\t\t\t\$this->set('data', \$this->params['data']);\n";
|
||||
$actions .= "\t\t\t\t\$this->validateErrors(\$this->{$controllerModel});\n";
|
||||
$actions .= "\t\t\t\t\$this->render();\n";
|
||||
$actions .= "\t\t\t}\n";
|
||||
$actions .= "\t\t}\n";
|
||||
|
@ -1131,7 +1139,7 @@ class Bake {
|
|||
$result = strtolower($unitTest) == 'y' || strtolower($unitTest) == 'yes';
|
||||
if ($result)
|
||||
{
|
||||
$this->stdout("\nYou can download the Cake test suite from http://ww.cakephp.org/", true);
|
||||
$this->stdout("\nYou can download the Cake test suite from http://cakeforge.org/frs/?group_id=62", true);
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -1268,7 +1276,7 @@ class Bake {
|
|||
}
|
||||
|
||||
$out .= "}\n";
|
||||
$out .= "?>\n";
|
||||
$out .= "?>";
|
||||
|
||||
$inflect = new Inflector();
|
||||
|
||||
|
@ -1367,7 +1375,7 @@ class Bake {
|
|||
$out .= $actions;
|
||||
|
||||
$out .= "}\n";
|
||||
$out .= "?>\n";
|
||||
$out .= "?>";
|
||||
|
||||
$filename = CONTROLLERS . $inflect->underscore($controllerName) . '_controller.php';
|
||||
|
||||
|
@ -1471,7 +1479,7 @@ class Bake {
|
|||
$this->stdout($prompt . " $print_options \n" . "[$default] > ", false);
|
||||
}
|
||||
|
||||
$result = trim(fgets(STDIN));
|
||||
$result = trim(fgets($this->stdin));
|
||||
|
||||
if($default != null && empty($result))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue